All threads / When run Rspec System testing, the API is not working

Ask A Question

Notifications

You’re not receiving notifications from this thread.

When run Rspec System testing, the API is not working

Kent asked in 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

Want to stay up-to-date with Ruby on Rails?

Join 53,130+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2021 GoRails, LLC. All rights reserved.