我原以为这个测试已经过去了。任何想法为什么它不是?
it 'should create an account' do
visit new_user_registration_path
fill_in 'user_email', with: 'newtest@test.com'
fill_in 'user_password', with: 'testing123'
fill_in 'user_password_confirmation', with: 'testing123'
expect{
click_button 'Sign Up'
}.to change{User.count}.by(1)
end
我得到了
result should have been changed by 1, but was changed by 0
答案 0 :(得分:0)
这是一个反缓存问题,请看: Rails counter_cache not updating correctly
答案 1 :(得分:0)
愚蠢的错误。我对用户的名称进行了验证!