0

我原以为这个测试会通过。任何想法为什么它不是?

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
4

2 回答 2

0

愚蠢的错误。我对用户名进行了验证!

于 2013-10-21T16:32:09.457 回答
0

这是一个计数器缓存问题,请参见: Rails counter_cache not updates correct

于 2013-10-21T13:08:13.643 回答