###前提
Rails4にてdeviseを用いて開発しています。
minitestを用い、integration_testを書いているなかで、同じコード、同じソースでもテスト結果が成功するときと失敗するときがあり困っています。
###エラーメッセージ
テストした際、下記のエラーが出る場合もあれば、出ない場合もあります。
下記のテストコードの最下部のテストを削除すると失敗することはないようです。
deviseのskip_confirmationあたりがなにかと干渉しているのかもしれませんがよくわかっていません・・・
もし気になる点やご存知のことがございましたらご教示いただけないでしょうか。
test_valid_signup_information FAIL (0.15s) Minitest::Assertion: "User.count" didn't change by 1. Expected: 3 Actual: 2 test/integration/users_signup_test.rb:20:in `block in <class:UsersSignupTest>'
###該当のテストコード
ruby
1require 'test_helper' 2 3class UsersSignupTest < ActionDispatch::IntegrationTest 4 5 # アカウント作成に失敗することを確認 6 test "invalid signup information" do 7 get new_user_registration_path 8 assert_no_difference 'User.count' do 9 post user_registration_path, user: { name: "", 10 email: "user@invalid", 11 password: "foo", 12 password_confirmation: "bar" } 13 end 14 assert_template 'devise/registrations/new' 15 end 16 17 # アカウント作成に成功することを確認 18 test "valid signup information" do 19 get new_user_registration_path 20 assert_difference 'User.count', 1 do 21 post_via_redirect user_registration_path, user: { name: "poeyama", 22 email: "user@example.com", 23 password: "password", 24 password_confirmation: "password" } 25 end 26 assert_template 'static_pages/home' 27 end 28 29 # アカウント作成に成功することを確認 30 test "valid login" do 31 user = users( :a1 ) 32 user.skip_confirmation! 33 log_in(user) 34 assert_not user.authenticated? 35 end 36end 37
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。