Ruby Mocha:是否有等同于rspec-mocks的#and_call_original? [英] Ruby Mocha: is there an equivalent to rspec-mocks' #and_call_original?

查看:28
本文介绍了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.

这篇关于Ruby Mocha:是否有等同于rspec-mocks的#and_call_original?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆