带参数的Rspec stub_chain

史蒂芬·默多克

我知道我可以执行以下操作:

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] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章