問題
さくっと確かめたいことがあり、system specがまず動くかどうかのスペックを書いた。実行すると以下のエラーがでた。
undefined local variable or method `new_user_session_path' for RSpec::ExampleGroups::Nested:Class
コードはこちら。
RSpec.describe "ユーザー登録", type: :system do visit new_user_registration_path expect(page).to have_http_status :ok end
解決
it
で囲っていないのが原因だった。
RSpec.describe "ユーザー登録", type: :system do it "登録" do visit new_user_registration_path expect(page).to have_http_status :ok end end
そもそもRSpecが動いてるかどうかのテストを書いてよかった。小さくテストをしたら、エラーの原因の範囲が絞られるので解明しやすい。