[rspec-users] Trying to write a failing test-- but am failing!

David Chelimsky dchelimsky at gmail.com
Tue Feb 16 21:18:51 EST 2010


On Tue, Feb 16, 2010 at 8:02 PM, patrick99e99 <patrick99e99 at gmail.com> wrote:
> Hi,
>
>> User.create(@invalid_attributes).should be_false # using create
>> instead of create!
>
> Hmmm..  when I tried this, I get:

Oops - it's this:

user = User.create(@invalid_attributes)
user.should_not be_valid

>
> 'User should fail when passwords do not match' FAILED
> expected #<User id: nil, login: "test_name", crypted_password:
> "e75e945946e0b31163c09da22ab0e8b725a89301d82275d0a90...",
> password_salt: "ivSY-ZjPwOiOoRfPfvAR", persistence_token:
> "9fa3b87bd2b8eb0d2ed600a0009f00ea4224de07954e96d7197...",
> single_access_token: "dGscUBSr_qJ3TTcHXpT3", 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 it this way, I got the same error as before--
>
> ActiveRecord::RecordInvalid in 'User should create a valid user'
> Validation failed: Password doesn't match confirmation

Try raise_error instead of raise_exception. If that works, you're
using an older version of rspec. If not, I'm not sure what's going on.


>
> -patrick
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list