前提・実現したいこと
rails でrails tutorialに沿って統合テストを書いていたところNoMethodError: undefined method `empty?' for nil:NilClassというエラーが検出されました。
元のオブジェクトをたどって解決しようと試みたのですが、そもそも'empty?'というメソッドの記述がないので、どこを確認していいかわからず、手詰まり状態です。
助けていただけるとありがたいです。お願いします。
該当のソースコード
Error:
UsersLoginTest#test_login_with_valid_information_followed_by_logout:
NoMethodError: undefined method `empty?' for nil:NilClass
integration/users_login_test.rb
1 test "login with valid information followed by logout" do 2 get login_path 3 post login_path, params: { session: { email: @user.email, 4 password: 'password' } } 5 assert is_logged_in? 6 assert_redirected_to @user 7 follow_redirect! 8 assert_template 'users/show' 9 assert_select "a[href=?]", login_path, count: 0 10 assert_select "a[href=?]", logout_path 11 assert_select "a[href=?]", user_path(@user) 12 delete logout_path 13 assert_not is_logged_in? 14 assert_redirected_to root_url 15 follow_redirect! 16 assert_select "a[href=?]", login_path 17 assert_select "a[href=?]", logout_path, count: 0 18 assert_select "a[href=?]", user_path(@user), count: 0 19 end
試したこと
binding.pryによるデバッグ
↓の記事も参考にしました
https://teratail.com/questions/74989
ここに問題に対して試したことを記載してください。
補足情報(FW/ツールのバージョンなど)
cloud9使用
Rails 5.0.7.2
あなたの回答
tips
プレビュー