[mocha-developer] Preview of Latest Mocha Changes

Frederick Cheung fred at 82ask.com
Thu Apr 12 14:10:05 EDT 2007


On 12 Apr 2007, at 18:21, James Mead wrote:
> - Anybody has a legitimate use for passing in an instance of Proc to
> Expectation#returns i.e. using the current behaviour where the Proc
> gets executed to generate a return value. I'm planning on deprecating
> this soon as well.

I use this. Some of my tests test that my models behave correctly in  
the presence of certain exception being thrown (eg a socket  
connection dieing, ActiveRecord raising a StaleObjectError etc...)
I use the Proc behaviour so that the first call raises and the second  
call doesn't i.e

actions = [lambda {raise Foo}, lambda {:blah}]
thing.stubs(:foo).returns(lambda {actions.shift.call})

Fred


More information about the mocha-developer mailing list