我知道我们通常不想在验收/特性测试中存根方法,但这是我在所有验收/特性测试中绝对需要存根的东西。
当我将存根调用放在env.rb的Before块中或在Background步骤中时,我得到了以下错误。
The use of doubles or partial doubles from rspec-mocks outside of the per-test lifecycle is not supported. (RSpec::Mocks::OutsideOfExampleError)我应该把存根调用放在哪里,这样它才能在所有情况下都能工作?
发布于 2015-04-07 18:12:31
我想这可能行得通:
RSpec::Mocks.with_temporary_scope do
allow_any_instance_of ....
end文档记录如下:
https://relishapp.com/rspec/rspec-mocks/docs/basics/scope
但实际上并不像我预期的那样工作-更好的解决方案是:
require 'cucumber/rspec/doubles'感谢Sanjay!@sanjsanj
文档记录如下:
https://github.com/cucumber/cucumber/wiki/Mocking-and-Stubbing-with-Cucumber
https://stackoverflow.com/questions/28485928
复制相似问题