On Jul 16, 2010, at 4:45 AM, Tom Stuart wrote:

> On 16 Jul 2010, at 10:29, Matt Wynne wrote:
>>> For those following along at home, this exact technique did not work. The 
>>> +actual_foo+ variable was holding some mock value instead of the real self 
>>> value.
>> Sorry. Do we think this is a bug in rspec? I'd have expected the block to 
>> return the last evaluated value. But is that just me?
> 
> It doesn't look like a bug to me -- I expect #should_receive to return a 
> message expectation, e.g. so that I can call #with/#and_return on it, and it 
> would seem weird for it to behave otherwise when a block is supplied.

Correct. The block syntax is an alternative to and_returns, and_yields, 
and_raises, etc. The block is evaluated lazily, when the stubbed or mocked 
method is invoked.

HTH,
David

> 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

Reply via email to