On Dec 5, 2007 9:07 AM, Tom Stuart <[EMAIL PROTECTED]> wrote: > 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.
This is true of the 1.0.8 release, but the current trunk does push :null_object down to the mock. > > 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 > _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users