<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:garamond,new york,times,serif;font-size:12pt">Cool, I'll use mock for this purpose in the future!<br><br>Al<div><div style="font-family: garamond,new york,times,serif; font-size: 12pt;"><br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Tom Stuart <tom@experthuman.com><br>To: rspec-users <rspec-users@rubyforge.org><br>Sent: Wednesday, December 5, 2007 7:07:55 AM<br>Subject: Re: [rspec-users] Does mock_model's :null_object option work?<br><br>
On 5 Dec 2007, at 14:52, Al Chou wrote:<br>> @order_address = mock_model( OrderAddress, :null_object => TRUE )<br>> Mock 'OrderAddress_1026' received unexpected message :first_name <br>> with (no args)<br>> so I'm starting to wonder whether the :null_object option is doing <br>> anything at all....<br><br>:null_object is an option to #mock, not #mock_model, which does call <br>down to #mock but doesn't pass any arguments through to it.<br><br>The optional hash argument to #mock_model allows you to stub specific <br>methods (in addition to #id, #to_param etc which #mock_model already <br>does for you), e.g. mock_model(OrderAddress, :first_name => <br>'Al', :last_name => 'Chou').<br><br>If you've got so many methods to stub that it's not worth doing it <br>explicitly, your best bet is probably to use #mock directly and <br>pass
:null_object.<br><br>Cheers,<br>-Tom<br>_______________________________________________<br>rspec-users mailing list<br><a ymailto="mailto:rspec-users@rubyforge.org" href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a><br><a href="http://rubyforge.org/mailman/listinfo/rspec-users" target="_blank">http://rubyforge.org/mailman/listinfo/rspec-users</a></div></div></div></div><br>
<hr size=1>Never miss a thing. <a href="http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs"> Make Yahoo your homepage.</a>
</body></html>