Hi,
> The create! method is designed to raise an error if validation fails.
> You can get this to work in one of two ways:
>
> User.create(@invalid_attributes).should be_false # using create
> instead of create!
Hmm, when I try that-- It still doesn't work...
it "should fail when passwords do not match" do
User.create(@invalid_attributes).should be_false
end
'User should fail when passwords do not match' FAILED
expected #<User id: nil, login: "test_name", crypted_password:
"7dc87663cf2600d1e14f8008b99beb458428aad4331765da0e9...",
password_salt: "UITwJqOSRNzvajFmKpxL", persistence_token:
"151252fc81a9990f8acbf689108b9a51239a9aa81f459ca8c75...",
single_access_token: "ZISHX20gtD4gCowZ2NLo", perishable_token: nil,
login_count: 0, failed_login_count: 0, last_request_at: nil,
current_login_at: nil, last_login_at: nil, current_login_ip: nil,
last_login_ip: nil, contact_id: nil, access_level_id: nil, active:
false, created_at: nil, updated_at: nil> to be false
> expect do
> User.create!(@invalid_attributes)
> end.to raise_exception(ActiveRecord::RecordInvalid)
And when I tried that way, I got the same error I was getting
originally:
it "should fail when passwords do not match" do
expect
do
User.create!
(@invalid_attributes)
end.to raise_exception(ActiveRecord::RecordInvalid)
end
ActiveRecord::RecordInvalid in 'User should create a valid user'
Validation failed: Password doesn't match confirmation
-p
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users