我在学习 Rspec 。 当我运行电子邮件验证的测试框时, 我得到一个无法理解的错误。 请解释 。
1) User should check for email validation
Failure/Error: @test_user.should have(1).errors_on(:email)
expected 1 errors on :email, got 2
# ./spec/models/user_spec.rb:17:in `block (2 levels) in <top (required)>
Finished in 0.12903 seconds
2 examples, 1 failure
我的测试案例如下:
it"should check whether name is present or not" do
@test_user.name = nil
@test_user.should have(1).errors_on(:name)
end
it "should check for email validation"do
@test_user.email = nil
@test_user.should have(2).errors_on(:email)
end
end