From e221264e74ae2826f876ae08c0cf54ecde07f073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20St=C4=99pie=C5=84?= Date: Mon, 5 Sep 2011 16:06:07 +0200 Subject: [PATCH] Fixed User specs broken in commit b33044 Expressions '...should == @user' caused specs to fail because of ArgumentError in 'User authentication resets password' wrong number of arguments (0 for 1) Replacing expectations declared for User objects with expectations declared for their id fields solves the problem and doesn't change specs' logic. --- spec/fixtures/users.yml | 4 ++-- spec/models/user_spec.rb | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/spec/fixtures/users.yml b/spec/fixtures/users.yml index dbb1cf19..cdd9a914 100644 --- a/spec/fixtures/users.yml +++ b/spec/fixtures/users.yml @@ -1,7 +1,7 @@ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html admin_user: login: admin - crypted_password: <%= BCrypt::Password.create("#{Tracks::Config.salt}--abracadabra--").to_s %> + crypted_password: <%= BCrypt::Password.create("abracadabra") %> token: <%= Digest::SHA1.hexdigest("adminSat Feb 25 17:14:00 GMT 20060.236961325863376") %> is_admin: true first_name: Admin @@ -10,7 +10,7 @@ admin_user: other_user: login: jane - crypted_password: <%= BCrypt::Password.create("#{Tracks::Config.salt}--sesame--").to_s %> + crypted_password: <%= BCrypt::Password.create("sesame") %> token: <%= Digest::SHA1.hexdigest("janeSun Feb 19 14:42:45 GMT 20060.408173979260027") %> is_admin: false first_name: Jane diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 3fd36dfa..035960ad 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -109,7 +109,7 @@ describe User do end it 'authenticates user' do - User.authenticate('simon', 'foobarspam').should == @user + User.authenticate('simon', 'foobarspam').id.should be @user.id end it 'resets password' do @@ -117,12 +117,13 @@ describe User do :password => 'new password', :password_confirmation => 'new password' ) - User.authenticate('simon', 'new password').should == @user + User.authenticate('simon', 'foobarspam').should be_nil + User.authenticate('simon', 'new password').id.should be @user.id end it 'does not rehash password after update of login' do @user.update_attribute(:login, 'foobar') - User.authenticate('foobar', 'foobarspam').should == @user + User.authenticate('foobar', 'foobarspam').id.should be @user.id end it 'sets remember token' do