[rspec-users] Does mock_model's :null_object option work?
hotfusionman at yahoo.com
Wed Dec 5 10:25:04 EST 2007
Cool, I'll use mock for this purpose in the future!
----- Original Message ----
From: Tom Stuart <tom at experthuman.com>
To: rspec-users <rspec-users at 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
rspec-users mailing list
rspec-users at rubyforge.org
Never miss a thing. Make Yahoo your home page.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rspec-users