[rspec-users] RSpec mock question

Patrick J. Collins patrick at collinatorstudios.com
Mon Jan 9 12:46:07 EST 2012

>           1) Foo should call new 3
>              Failure/Error: Unable to find matching line from backtrace
>                Exactly one instance should have received the following
> message(s) but didn't: new3
> How can I change the spec to make this pass (while verifying that new3
> was called)?
This probably isn't working because .new3 is a class method, and you are
setting an expectation for an instance method to be called.  The way I
would do this would be something like:

client = stub("XMLRPC::Client", :new3 => true)

Patrick J. Collins

More information about the rspec-users mailing list