[rspec-users] Suggested shorthand for and_return when stubbing

Matt Wynne matt at mattwynne.net
Sat Feb 20 17:09:15 EST 2010


I keep wanting to do this, and I don't think it's possible so I  
thought I'd suggest it. Similarly to the way I can specify stub values  
as hash key/value pairs when constructing a test double, I'd like to  
be able to the same when subsequently calling stub on that double:

     me.stub(:name => 'Matt')

That's as opposed to

     me.stub(:name).and_return('Matt')

Thoughts?

cheers,
Matt

http://mattwynne.net
+447974 430184



More information about the rspec-users mailing list