[rspec-users] Post call verification

Srushti Ambekallu srushti at ambekallu.com
Fri Mar 18 11:37:42 EDT 2011

Hey all,

I would like to be able to be able to have mocks where I can make all 
the calls and assert that it was called afterwards. This would be 
especially useful when asserting on a doing-method whose return value is 
not being considered.

    service = mock(ExternalService)
    user = User.new

Now this obviously can't replace all assertions done with 
should_receive, but I know there are at least a few cases where this 
would come in handy and be more readable. I know while writing tests, I 
usually write the actual call (in this case the 'post') and then go up a 
couple of lines to write the should_receive. I think it would be more 
natural to verify it after the fact rather than before. I seem to 
remember there was another mocking library which did something quite 
close to this, but I just can't seem to find it just now. What does 
everyone think? I could try and implement this myself, but just wanted 
to see if there was any interest, or any one had a good reason not to 
include this.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110318/f91f35d5/attachment.html>

More information about the rspec-users mailing list