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.

Reply
Join the discussion
Create an account Log in

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

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

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

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

    © 2024 GoRails, LLC. All rights reserved.