[rspec-users] What argument should I pass for mock(), stub() and double()

David Chelimsky dchelimsky at gmail.com
Sun Oct 11 08:20:17 EDT 2009

On Oct 11, 2009, at 6:21 AM, Lee Hambley wrote:

> John,
> I may well be wrong, but I believe it's just a `tag` or name, so  
> when you print out <customer> - you see <#Double customer> rather  
> tahn something inexplicable, that is at least how it appears to work  
> using Mocha

Not so much when _you_ print it out, but when there is a failure and  
rspec prints out a failure message for you. This is actually explained  
in the book - on page 207 if you've got beta 10:

To create a double, just use the double( ) method, like this:

thingamajig_double = double('thing-a-ma-jig')

The string argument is optional, but highly recommended as it is used  
in failure messages.

> - Lee
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list