[rspec-users] Rspec approach to test model

Kaleem Ullah lists at ruby-forum.com
Wed Feb 11 12:50:05 EST 2009

Nick Hoffman wrote:
> To spec your #activate! , why not do something like this?:
> it 'should activate the user' do
>    @user.active.should be_false
>    @user.activate!
>    @user.active.should be_true
> end

Thanks for your reply Hoffman :)

I did the same but it gives error like "#23000Duplicate entry 
'kkkkk at gmail.com Insert INTO (...) Values(...)".
It should do update not Insert.
But when i try call it with a new instance of user (with no values 
assigned to any user attribute) then it works.
it "should activate the user" do
This works.

I think i have to erase all the User attributes from "before (:each)" 
and only assigned it in Examples which required it. am i right ?

Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list