Ruby Mocha:是否有等同于rspec-mocks的#and_call_original?
问题描述:
Rspec-mocks具有expect(some_object).to receive(:some_method).and_call_original
.我可以用Mocha做到这一点吗?如果可以,怎么办? some_object.expects(:some_method)....
...什么?
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?
答
我很确定没有办法做到这一点.
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.