yan*_*man 5 stub cucumber capybara
我知道我们通常不希望在接受/功能测试中存根方法,但这是我绝对需要为所有接受/功能测试存根的东西.
当我Before在env.rb或Background步骤中将存根调用置于块中时,我收到以下错误.
The use of doubles or partial doubles from rspec-mocks outside of the per-test lifecycle is not supported. (RSpec::Mocks::OutsideOfExampleError)
Run Code Online (Sandbox Code Playgroud)
我应该在哪里放置存根调用,以便它可以在所有情况下工作?
我认为这可能有效:
RSpec::Mocks.with_temporary_scope do
allow_any_instance_of ....
end
Run Code Online (Sandbox Code Playgroud)
记录在这里:
https://relishapp.com/rspec/rspec-mocks/docs/basics/scope
但实际上并没有按我预期的那样工作-更好的解决方案是:
require 'cucumber/rspec/doubles'
Run Code Online (Sandbox Code Playgroud)
感谢桑杰!@sanjsanj
记录在这里:
https://github.com/cucumber/cucumber/wiki/Mocking-and-Stubbing-with-Cucumber
| 归档时间: |
|
| 查看次数: |
1382 次 |
| 最近记录: |