[Double-ruby-users] Stubbing — could it be simpler....

Mark - mkdynamic markdodwell at gmail.com
Sun Feb 22 12:05:04 EST 2009


When stubbing with RR, defining one circumstance requires you to
define a default one too:

   stub(MyClass).find(1).returns(@one)
   stub(MyClass).find { |v| v }

With Mocha, you can simply do:

   MyClass.stubs(:find).with(1).returns(@one)

Isn't this better and more terse — or am I missing something!?

What are your thoughts on this?

Thanks,

~ Mark Dodwell


More information about the Double-ruby-users mailing list