[rspec-users] how can this pass?

David Chelimsky dchelimsky at gmail.com
Sun Feb 8 22:29:59 EST 2009


On Sun, Feb 8, 2009 at 8:54 PM, Sergio Bayona <lists at ruby-forum.com> wrote:
> Aslak Hellesøy wrote:
>> On Mon, Feb 9, 2009 at 2:35 AM, Sergio Bayona <lists at ruby-forum.com>
>> wrote:
>>>
>>>        assigns[:property].should equal(mock_property)
>>> 1 example, 0 failures
>>>
>>>
>>> why zero failures? more specifically, why would :non_existing_method
>>> return mock_property?
>>
>> Because you have stubbed the class method Property#non_existing_method
>> with:
>>   Property.should_receive(:non_existing_method).and_return(mock_property)
>>
>> It doesn't make any difference whether this method is already defined
>> or not. Once the stub is set up, calls to the stubbed method will
>> return what you told it to return.
>>
>>> and why would the assigns[:property] be equal to
>>> mock_property?
>>
>> Because your controller's #show method assigns @property with the
>> value returned from Property#non_existing_method (which you stubbed).
>>
>>> did I eat some bad mushrooms?
>>>
>>
>> That I don't know. Why do you think this behaviour is
>> strange/hallucinating?
>>
>> Aslak
>
>
> ah! okay it's starting to make sense... and the mushroom effect is
> wearing out. just kidding ;)
>
> Thank you guys. By the way I just bought the "Rspec Book" and it's seems
> like a great resource. It has encouraged me to learn the framework.

That's great news, thanks! If you have any constructive feedback to
provide about the book, please do so at:

http://www.pragprog.com/titles/achbd/errata
http://forums.pragprog.com/forums/95

Cheers,
David

>
> Sergio
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users


More information about the rspec-users mailing list