Ruby Mocha: is there an equivalent to rspec-mocks' #and_call_original?
Asked Answered
C

1

21

Rspec-mocks has expect(some_object).to receive(:some_method).and_call_original. Can I do this with Mocha, and if so, how? some_object.expects(:some_method).... ...what?

Carnay answered 11/2, 2014 at 23:10 Comment(1)
To help searchers find this page: What's being asked for here is called a spy in some other mocking frameworks. See e.g. relishapp.com/rspec/rspec-mocks/docs/basics/spiesFtlb
C
14

I'm fairly sure that there isn't a way to do this.

Looking through the source code, there's a comment that mentions that the original method is completely replaced.

# The original implementation of the method is replaced during the test and then restored at the end of the test. The temporary replacement method has the same visibility as the original method.
Cotopaxi answered 29/3, 2014 at 6:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.