我知道我可以执行以下操作:
Foo.stub_chain(:bar, :baz).with(:marflar).with(:quux)
这会打断对
Foo.bar(:marflar).baz(:quux)
但是,如果我想删除提供给我的参数,该baz
怎么办?IE
Foo.bar(:marflar).baz
要匹配不带任何参数的呼叫,可以使用with(no_args)
。如果您不关心参数,请使用with(any_args)
。有更多的匹配器可用。
所以要匹配这个:
Foo.bar(:marflar).baz
用这个:
# expect no arguments
Foo.stub_chain(:bar, :baz).with(:marflar).with(no_args)
# expect 0 or any arguments
Foo.stub_chain(:bar, :baz).with(:marflar).with(any_args)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句