Cool, I'll use mock for this purpose in the future!

Al

----- Original Message ----
From: Tom Stuart <[EMAIL PROTECTED]>
To: rspec-users <rspec-users@rubyforge.org>
Sent: Wednesday, December 5, 2007 7:07:55 AM
Subject: Re: [rspec-users] Does mock_model's :null_object option work?


On 5 Dec 2007, at 14:52, Al Chou wrote:
>   @order_address = mock_model( OrderAddress, :null_object => TRUE )
> Mock 'OrderAddress_1026' received unexpected message :first_name  
> with (no args)
> so I'm starting to wonder whether the :null_object option is doing  
> anything at all....

:null_object is an option to #mock, not #mock_model, which does call  
down to #mock but doesn't pass any arguments through to it.

The optional hash argument to #mock_model allows you to stub specific  
methods (in addition to #id, #to_param etc which #mock_model already  
does for you), e.g. mock_model(OrderAddress, :first_name =>  
'Al', :last_name => 'Chou').

If you've got so many methods to stub that it's not worth doing it  
explicitly, your best bet is probably to use #mock directly and  
pass :null_object.

Cheers,
-Tom
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users





      
____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to