是否可以检查传递给方法调用参数的参数是否满足某些约束.我想做点什么
my_double = double("MyObject")
my_double.should_receive(:mocked_method).with{ <something that has an attribute called name and value "john"> }
Run Code Online (Sandbox Code Playgroud)
非常感谢提前.
编辑:我会尝试澄清一下我想要完成的事情
我想要的是检查模拟的给定方法是否被调用传递满足某些条件的对象
作为记录.我想要完成的是什么
@test_double.should_receive(:send_mail) do |mail|
mail.to.should eq(["john@aol.com"])
mail.body.decoded.should include "Error"
end
Run Code Online (Sandbox Code Playgroud)
并且代码应该使用满足块中指定条件的参数调用给定对象的方法send_mail.
| 归档时间: |
|
| 查看次数: |
3700 次 |
| 最近记录: |