[rspec-users] what's the meaning of to_param?
zach.dennis at gmail.com
Thu Mar 19 09:20:16 EDT 2009
On Thu, Mar 19, 2009 at 9:15 AM, Zach Dennis <zach.dennis at gmail.com> wrote:
> On Thu, Mar 19, 2009 at 8:46 AM, Zhenning Guan <lists at ruby-forum.com> wrote:
>> usually, I just use this way.
>> @weather = mock_model(Weather)
>> but recently I saw this. so what's the :to_param and :save options
>> @weather = mock_model(Weather, :to_param => "1", :save => true)
> It's a Rails thing, used when converting an object to a URL representation.
Oops, sorry, I misread your question.
mock_model will provide you with #to_param so the only thing I can
think w/o knowing more is if whoever wrote the spec wanted to
specifically expect, look for, or somehow use the "1" that came from
to_param. They wanted to know that specific the result of
@weater.to_param was being used (which will be used be number of Rails
My best guess on the save call is that the implementation is going to
call save, and the author of the spec by default wants it to be
successful for any subsequent examples.
>> Posted via http://www.ruby-forum.com/.
>> rspec-users mailing list
>> rspec-users at rubyforge.org
> Zach Dennis
More information about the rspec-users