New Discussion

Notifications

You’re not receiving notifications from this thread.

When run Rspec System testing, the API is not working

0
Rails

I am currently using rails 6. When I run the Rspec system testing, the API cannot pass data to my index page. Here is my test code:
require "rails_helper"
require_relative "../support/devise"

RSpec.feature "Dash Chart", type: :system, js: true do
  let!(:user) { create(:user) }

  it "should show the chart with data" do
  visit "/users/sign_in"

  fill_in "Email", with: "chris@wallstpigeon.com"
  fill_in "Password", with: "password"
  click_button "Log in"

  visit "/dashboard"

  click_button "Search"
  expect(page).to have_content("Search")


 end

end
And the error is:

Dash Chart should show the chart with data
Failure/Error: @index_chartdata ||= @raw_chartdata.map { |n| [n["minute"], n["close"]] }

NoMethodError:
undefined method `map' for nil:NilClass

The map function aim to get specific chart data from API response body.

Join the discussion
Create an account Log in

Learning Ruby on Rails? Join our newsletter.

We won't send you spam. Unsubscribe at any time.