Ruby 规范定义了 3 个 instance_doubles:
let(:doub1) { instance_double(Foo) }
let(:doub2) { instance_double(Foo) }
let(:doub3) { instance_double(Foo) }
shared_example 旨在确保协作者与任何 instance_doubles 一起使用:
shared_examples :a_consumer_of_bars do
it "passes a Foo to the BarGetter" do
expect(BarGetter).to receive(:fetch_bar)
.with((condition1 || condition2 || condition3)).at_least(:once)
subject
end
end
(piped||arguments||approach) 不起作用。是否存在用于检查参数是否匹配数组元素的现有 rspec 匹配器?还是编写自定义匹配器是可行的方式?