50 Experience
0 Lessons Completed
0 Questions Solved


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: ""
  fill_in "Password", with: "password"
  click_button "Log in"

  visit "/dashboard"

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


And the error is:

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

undefined method `map' for nil:NilClass

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

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.