My team uses Mocha for unit testing in Ruby. I'd like to use Mocha to add a "spy" on a method. That is, I'd like to write a unit test using Mocha that verifies that the code under test calls a particular method on another class, without overriding the implementation of that method.
Is that possible? If so, how can it be done?
I've tried using Mocha's
However, that overrides the implementation of
my_method. In my particular situation, I need to both verify that
my_method was called, and to have the actual implementation of the method execute during the test.