My question is similar to this one: Mocha: stubbing method with specific parameter but not for other parameters
obj.expects(:do_something).with(:apples).never
perform_action_on_obj
The perform_action_on_obj
will not call do_something(:apples)
as I expect. However, it may call do_something(:bananas)
. If it does, I get an unexpected invocation failure.
My understanding is that since I placed never
at the end of the expectation, it only applied to that specific modified expectation. However it appears that once I start mocking behavior on obj
I've "screwed it up" in a sense.
How can I allow other invocations of the do_something
method on obj
?
EDIT: Here is a clear cut example that demonstrates my issue perfectly:
describe 'mocha' do
it 'drives me nuts' do
a = mock()
a.expects(:method_call).with(:apples)
a.lol(:apples)
a.lol(:bananas) # throws an unexpected invocation
end
end