RSpec: "expect with" 与 fastlane 一起使用时从错误模块调用的函数

RSpec: "expect with" function called from the wrong module when used with fastlane

我想将 RSpec 与 fastlane 一起使用,并进行了 RSpec 建议的设置。如果使用正确的参数调用函数,我想检查我的测试。我使用此处的示例代码来检查这一点: https://relishapp.com/rspec/rspec-mocks/v/3-2/docs/setting-constraints/matching-arguments

require 'spec_helper'
require 'rspec'

RSpec.describe "Constraining a message expectation using with" do
  let(:dbl) { double }
  before { expect(dbl).to receive(:foo).with(1, anything, /bar/) }


  it "passes when the args match" do
    dbl.foo(1, nil, "barn")
  end

  it "fails when the args do not match" do
    dbl.foo(1, nil, "other")
  end
end

当我使用 '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' 取自 facets/kernel/with.rb 中的另一个模块,而不是正确取自 rspec_mocks 文件。

如何确保调用了正确的函数?为什么一开始就调用了这个错误的函数?

在此先感谢您的帮助!

事实证明这不是 fastlane 的问题,而是我们添加到项目中的依赖项的问题。该依赖项称为 facets,它包括 a file,它全局覆盖每个名为 with.

的函数

我在他们的 GitHub 上报告了这件事,我现在正在等待他们的答复。 Link to report