我有一个ActionController::TestCase失败了,我不知道为什么。
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: 'alice@example.com',
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
有没有办法让帖子告诉我错误是什么?例如,有没有一种方法可以访问errors
数组以errors.full_messages
在出现错误时调用通常在结果视图中可用的方法?