Ruby RSpec:“是的;用“期待”;与fastlane一起使用时从错误模块调用的函数

Ruby RSpec:“是的;用“期待”;与fastlane一起使用时从错误模块调用的函数,ruby,rspec,fastlane,Ruby,Rspec,Fastlane,我想将RSpec与fastlane一起使用,并完成了RSpec建议的设置。我想在测试中检查是否使用正确的参数调用了函数。我使用这里的示例代码来准确地检查: 当我使用'rspec'执行此操作时,这很好。没有错误,我得到了预期的结果 但是,如果我像这样在spec_helper.rb文件中加载fastlane操作 $LOAD_PATH.unshift File.expand_path('..', __dir__) module SpecHelper end require 'fastlane'

我想将RSpec与fastlane一起使用,并完成了RSpec建议的设置。我想在测试中检查是否使用正确的参数调用了函数。我使用这里的示例代码来准确地检查:

当我使用'rspec'执行此操作时,这很好。没有错误,我得到了预期的结果

但是,如果我像这样在spec_helper.rb文件中加载fastlane操作

$LOAD_PATH.unshift File.expand_path('..', __dir__)

module SpecHelper
end

require 'fastlane'

Fastlane.load_actions
Fastlane.plugin_manager.load_plugins
我突然发现以下错误:

Constraining a message expectation using with passes when the args match
 Failure/Error: before { expect(dbl).to receive(:foo).with(1, anything, /bar/) }

 ArgumentError:
   wrong number of arguments (given 3, expected 0..1)
 # /Users/philip.otto/.rvm/gems/ruby-2.6.0/gems/facets-3.1.0/lib/core/facets/kernel/with.rb:15:in `with'
 # ./spec/iz_create_release_branch_spec.rb:8:in `block (2 levels) in <top (required)>'
在参数匹配时使用with PASS约束消息期望
失败/错误:在{expect(dbl).to receive(:foo).with(1,anything,/bar/)}之前
参数错误:
参数数目错误(给定3,应为0..1)
#/Users/philip.otto/.rvm/gems/ruby-2.6.0/gems/facets-3.1.0/lib/core/facets/kernel/with.rb:15:in`with'
#./spec/iz_创建_发布_分支_spec.rb:8:in `分块(2层)'
因此,问题似乎是错误的函数“with”取自facets/kernel/with.rb中的另一个模块,而不是正确取自rspec_mock文件

如何确保调用了正确的函数?为什么首先调用这个错误的函数


提前感谢您的帮助

事实证明,这不是fastlane的问题,而是我们添加到项目中的依赖关系。依赖项称为facets,它包括全局覆盖使用调用的每个函数的facets

我在他们的GitHub上报告了这一点,现在我正在等待他们的答复。

我相信
在{expect(dbl)之前。接受(:foo)。有(1,anything,/bar/)}
应该是
在{allow(dbl)之前。接受(:foo)。有(1,anything,/bar/)}
亚历克斯的建议可能就是答案。我习惯于将期望放在示例中(即)。我喜欢这个网站教我的方式Rspec:@AlexGolubenko。谢谢你的意见!代码100%复制自rspec页面。允许和期望是两件不同的事情。问题是“with”函数被我们使用的facets gem覆盖。我们目前正在缩小问题范围。没有问题:-)
Constraining a message expectation using with passes when the args match
 Failure/Error: before { expect(dbl).to receive(:foo).with(1, anything, /bar/) }

 ArgumentError:
   wrong number of arguments (given 3, expected 0..1)
 # /Users/philip.otto/.rvm/gems/ruby-2.6.0/gems/facets-3.1.0/lib/core/facets/kernel/with.rb:15:in `with'
 # ./spec/iz_create_release_branch_spec.rb:8:in `block (2 levels) in <top (required)>'