皆さん、こんにちは。
Rails Tutorial第4版、10章を学習しています。
【リスト 10.28: 最終的なcorrect_userの実装】までテストが通るんですが
【リスト 10.33】のテストが通りません。
どなたか分かる方ご教示頂けますか?
以下がテストの結果です。
xxxxxxxxxxxxxxxxxxxxxxxxxxx:sample_app xxxxxxxxx$ bundle exec rake test DEPRECATION WARNING: Sprockets method `register_engine` is deprecated. Please register a mime type using `register_mime_type` then use `register_compressor` or `register_transformer`. https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors (called from block (2 levels) in <class:Railtie> at /Users/xxxxxxxxx/.rvm/gems/ruby-2.2.5/gems/sass-rails-5.0.2/lib/sass/rails/railtie.rb:57) DEPRECATION WARNING: Sprockets method `register_engine` is deprecated. Please register a mime type using `register_mime_type` then use `register_compressor` or `register_transformer`. https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors (called from block (2 levels) in <class:Railtie> at /Users/xxxxxxxxx/.rvm/gems/ruby-2.2.5/gems/sass-rails-5.0.2/lib/sass/rails/railtie.rb:58) Run options: --seed 10105 # Running: ..................F..............DEPRECATION WARNING: The assertion was not run because of an invalid css selector. unexpected '$' after '[:equal, "\"/login\""]' (called from block in <class:UsersLoginTest> at /Users/xxxxxxxxx/workspace/sample_app/test/integration/users_login_test.rb:34) DEPRECATION WARNING: The assertion was not run because of an invalid css selector. unexpected '$' after '[:equal, "\"/logout\""]' (called from block in <class:UsersLoginTest> at /Users/xxxxxxxxx/workspace/sample_app/test/integration/users_login_test.rb:35) DEPRECATION WARNING: The assertion was not run because of an invalid css selector. unexpected '$' after '[:equal, "\"/users/762146111\""]' (called from block in <class:UsersLoginTest> at /Users/xxxxxxxxx/workspace/sample_app/test/integration/users_login_test.rb:36) ... Finished in 1.560245s, 23.0733 runs/s, 76.9110 assertions/s. 1) Failure: UsersSignupTest#test_valid_signup_information_with_account_activation [/Users/xxxxxxxxx/workspace/sample_app/test/integration/users_signup_test.rb:41]: expecting <"user/show"> but rendering with <["users/show", "layouts/_shim", "layouts/_header", "layouts/_footer", "layouts/application"]> 36 runs, 120 assertions, 1 failures, 0 errors, 0 skips Time: 00:00:00, ETA: 00:00:0 ERROR["test_login_with_remembering", Minitest::Result,01947229891084] test_login_with_remembering#Minitest::Result (0.53s) NoMethodError: NoMethodError: undefined method `remember_token' for nil:NilClass test/integration/users_login_test.rb:45:in `block in <class:UsersLoginTest>' E 35/2: [=======] 5% Time: 00:00:00, ETA: 00:00:09 Error: UsersLoginTest#test_login_with_remembering: NoMethodError: undefined method `remember_token' for nil:NilClass test/integration/users_login_test.rb:45:in `block in <class:UsersLoginTest>'
以下がエラーが記載しているファイルの場所です。
require 'test_helper' class UsersLoginTest < ActionDispatch::IntegrationTest def setup @user = users(:michael) end test "login with invalid information" do get login_path assert_template 'sessions/new' post login_path, params: { session: { email: "", password: "" } } assert_template 'sessions/new' assert_not flash.empty? get root_path assert flash.empty? end test "login with valid information followed by logout" do get login_path post login_path, params: { session: { email: @user.email, password: 'password' } } assert is_logged_in? assert_redirected_to @user follow_redirect! assert_template 'users/show' assert_select "a[href=?]", login_path, count: 0 assert_select "a[href=?]", logout_path assert_select "a[href=?]", user_path(@user) delete logout_path assert_not is_logged_in? assert_redirected_to root_url # 2番目のウィンドウでログアウトをクリックするユーザーをシミュレートする delete logout_path follow_redirect! assert_select "a[href=?]", login_path assert_select "a[href=?]", logout_path, count: 0 assert_select "a[href=?]", user_path(@user), count: 0 end test "login with remembering" do log_in_as(@user, remember_me: '1') assert_equal cookies['remember_token'], assigns(:user).remember_token end test "login without remembering" do # クッキーを保存してログイン log_in_as(@user, remember_me: '1') delete logout_path # クッキーを削除してログイン log_in_as(@user, remember_me: '0') assert_empty cookies['remember_token'] end end
以下が実行環境になります。
Running via Spring preloader in process 1739 About your application's environment Rails version 5.1.4 Ruby version 2.4.0-p0 (x86_64-linux) RubyGems version 2.6.8 Rack version 2.0.5 JavaScript Runtime Node.js (V8) Middleware Rack::Sendfile, ActionDispatch::Static, ActionDispatch::Executor, ActiveSupport::Cache::Strategy::LocalCache::Middleware, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, ActionDispatch::RemoteIp, Sprockets::Rails::QuietAssets, Rails::Rack::Logger, ActionDispatch::ShowExceptions, WebConsole::Middleware, ActionDispatch::DebugExceptions, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, Rack::Head, Rack::ConditionalGet, Rack::ETag Environment development Database adapter sqlite3 Database schema version 20180813205653
以上です、よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/08/15 05:56
2018/08/15 06:59
2018/08/15 07:04
2018/08/15 07:05
2018/08/15 07:13 編集
2018/08/15 07:19 編集
2018/08/15 07:32 編集
2018/08/15 07:34
2018/08/15 07:42
2018/08/15 07:43
2018/08/15 08:12
2018/08/15 09:59
2018/08/15 10:06 編集
2018/08/15 10:26
2018/08/15 10:39