Re: [rspec-users] before_save model callback rspec testing

2008-06-24 Thread Csongor Bartus
Yi Wen wrote: > That's because you executed the same creation code into the > script/console, which has nothing to do with RSpec, and still get the > same error message, right? > > Yi Gotcha :D It seems I've got tired ... Thanks a lot! -- Posted via http://www.ruby-forum.com/. __

Re: [rspec-users] before_save model callback rspec testing

2008-06-24 Thread Yi Wen
That's because you executed the same creation code into the script/console, which has nothing to do with RSpec, and still get the same error message, right? Yi On Tue, Jun 24, 2008 at 2:56 AM, Csongor Bartus <[EMAIL PROTECTED]> wrote: > Yi Wen wrote: >> Well, at least now we know this is nothing

Re: [rspec-users] before_save model callback rspec testing

2008-06-24 Thread Csongor Bartus
Yi Wen wrote: > Well, at least now we know this is nothing to do with RSpec. My > suggestion is that you comment out the code which will be executed > during a creation, bit by bit in User (such as before_save) and try to > create a user. In this way you can pinpoint where the problem is. Thanks a

Re: [rspec-users] before_save model callback rspec testing

2008-06-23 Thread Yi Wen
Well, at least now we know this is nothing to do with RSpec. My suggestion is that you comment out the code which will be executed during a creation, bit by bit in User (such as before_save) and try to create a user. In this way you can pinpoint where the problem is. On Mon, Jun 23, 2008 at 10:26

Re: [rspec-users] before_save model callback rspec testing

2008-06-23 Thread Csongor Bartus
Yi Wen wrote: > You don't have attr_accessor :password, :password_confirmation in > User, do you? You may want to add this and try again I had :password, I've added :password_confirmation but still the same: >> u = User.create!(:login => "test", :email => "[EMAIL PROTECTED]", :password >> => "te

Re: [rspec-users] before_save model callback rspec testing

2008-06-23 Thread Yi Wen
You don't have attr_accessor :password, :password_confirmation in User, do you? You may want to add this and try again On Mon, Jun 23, 2008 at 9:59 AM, Csongor Bartus <[EMAIL PROTECTED]> wrote: > Yi Wen wrote: >> fire up script/console and copy line 82 and try it out. and report the >> result here

Re: [rspec-users] before_save model callback rspec testing

2008-06-23 Thread Csongor Bartus
Yi Wen wrote: > fire up script/console and copy line 82 and try it out. and report the > result here. >> u = User.create!(:login => "test", :email => "[EMAIL PROTECTED]", :password >> => "test123", :password_confirmation => "test123") NoMethodError: You have a nil object when you didn't expect it

Re: [rspec-users] before_save model callback rspec testing

2008-06-23 Thread Yi Wen
fire up script/console and copy line 82 and try it out. and report the result here. On Fri, Jun 20, 2008 at 11:11 AM, Csongor Bartus <[EMAIL PROTECTED]> wrote: > David Chelimsky wrote: > >> >> Try using create! or save! - I'll bet the record is not being saved >> correctly and you're not seeing th

Re: [rspec-users] before_save model callback rspec testing

2008-06-20 Thread Csongor Bartus
[Offtopic question] I might be paranoic testing if the password is salted/hashed correctly since all my login tests passed? In learning RSpec I find the most important to draw a line and don't look behind ... but what if, in this case, accidentally something happens with 'digest/sha1' and the

Re: [rspec-users] before_save model callback rspec testing

2008-06-20 Thread Csongor Bartus
David Chelimsky wrote: > > Try using create! or save! - I'll bet the record is not being saved > correctly and you're not seeing the error. done, still the same errors (exactly) -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rs

Re: [rspec-users] before_save model callback rspec testing

2008-06-20 Thread David Chelimsky
On Jun 20, 2008, at 11:01 AM, Csongor Bartus wrote: I'm trying "your" way: u = User.create(:login => "test", :email => "[EMAIL PROTECTED]", :password => "test123", :password_confirmation => "test123") u.crypted_password.should_not be_nil the error message is: NoMethodError in 'User ActiveRecord

Re: [rspec-users] before_save model callback rspec testing

2008-06-20 Thread Csongor Bartus
Thanks Pat, I've tried this way but the test did not passed ... I'm trying to Rspec Authorization's plugin User class (http://www.writertopia.com/developers/authorization) Which looks like this: # == Schema Information # Schema version: 92 # # Table name: users # # id:i

Re: [rspec-users] before_save model callback rspec testing

2008-06-20 Thread Pat Maddox
Hey, This isn't doing much to test the *behavior* of the object. Why do you want to encrypt the password? Probably so you can authenticate, right? I would probably start off with describe "authenticate" do it "finds the user with the given credentials" do u = User.create!(:login => "pat"

Re: [rspec-users] before_save model callback rspec testing

2008-06-20 Thread Csongor Bartus
It might be I've done this : it "should encrypt password before save" do user = mock("User") user.should_receive(:encrypt_password).with("password") user.save end but I've got : Spec::Mocks::MockExpectationError in 'User ActiveRecord Callbacks before save encrypt passwor

Re: [rspec-users] before_save model callback rspec testing

2008-06-20 Thread Yi Wen
user.should_receive(:encrypt_password).with(your_password) user.save Is this what you want? On Fri, Jun 20, 2008 at 10:12 AM, Csongor Bartus <[EMAIL PROTECTED]> wrote: > hi all, > > i'm learning rspec and i can't figure out how to test if a callback is > executed in a model. > > my model code is: