I would have thought this test would have passed. Any ideas why it isnt?
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
I just get
result should have been changed by 1, but was changed by 0
这是计数器缓存问题,请参见: Rails counter_cache无法正确更新
Silly mistake. I had a validation on user for name!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.