0
我有一個ActionController::TestCase這是失敗的,我不知道爲什麼。在Rails系統測試中查看失敗觸發器
require 'test_helper'
class UsersControllerTest < ActionController::TestCase
setup do
@user = users(:bob)
sign_in @user
end
test "should create user" do
assert_difference('User.count') do
post :create, user: {
first_name: 'Alice',
email: '[email protected]',
password: 'adflihbrgshbart'
}
end
end
end
結果是
Failure:
UsersControllerTest#test_should_create_user [.../dev/test/controllers/users_controller_test.rb:23]
Minitest::Assertion: "User.count" didn't change by 1.
Expected: 5
Actual: 4
有沒有辦法有post告訴我什麼是錯誤?例如,有沒有一種方法可以訪問errors
數組以調用errors.full_messages
,當出現錯誤時,通常可以在結果視圖中使用該數組?