Hunt Jon
2009-Oct-11 06:00 UTC
[rspec-users] What argument should I pass for mock(), stub() and double()
Hi - I''m reading the RSpec book. I see an example like: customer = double(''customer'') What is the customer that is in the argument for? How is this different from: customer = double() ? Can anybody explain to me? - Jon
Lee Hambley
2009-Oct-11 09:21 UTC
[rspec-users] What argument should I pass for mock(), stub() and double()
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 - Lee -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20091011/e44b9c6f/attachment.html>
David Chelimsky
2009-Oct-11 12:20 UTC
[rspec-users] What argument should I pass for mock(), stub() and double()
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 MochaNot 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: <snip> 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. </snip>> - Lee > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users