ruby 摩卡 : is there an equivalent to rspec-mocks' #and_call_original?

标签 ruby ruby-mocha

Rspec-mocks 具有expect(some_object).to receive(:some_method).and_call_original。我可以用 Mocha 做这个吗?如果可以,怎么做? some_object.expects(:some_method).... ...什么?

最佳答案

我相当确定没有办法做到这一点。

浏览source code , 有评论提到完全替换了原来的方法。

# 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 摩卡 : is there an equivalent to rspec-mocks' #and_call_original?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21715174/

相关文章:

ruby - 接收 block 作为参数的模拟方法

ruby 摩卡 : is there an equivalent to rspec-mocks' #and_call_original?

ruby - 返回结果和模数的方法

ruby-on-rails - 如何给用户一个文件存储限制?

javascript - ProfilesController 中没有方法错误#show

ruby-on-rails - ActiveRecord 'no method found' 简单一对多关系异常

ruby - 使用 Ruby 进行测试驱动开发

ruby-on-rails - 模拟/ stub "instance.extend(DecoratorModule)"中包含的方法