简体   繁体   English

简单的rspec测试失败

[英]Simple rspec test failing

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! 我已经验证了用户的姓名!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM