在RSpec测试中,如何验证方法调用时使用了参数double的ruby代码?
- 内容介绍
- 文章标签
- 相关推荐
本文共计241个文字,预计阅读时间需要1分钟。
是否可以检查传递给方法调用的参数是否符合某些约束。我想做的是 +my_double=double(MyObject) my_double.should_receive(:mocked_method).with { something that has an attribute called name and value john } 非常正常。
my_double = double("MyObject") my_double.should_receive(:mocked_method).with{ <something that has an attribute called name and value "john"> }
非常感谢提前.
编辑:我会尝试澄清一下我想要完成的事情
我想要的是检查模拟的给定方法是否被调用传递满足某些条件的对象
作为记录.我想要完成的是什么@test_double.should_receive(:send_mail) do |mail| mail.to.should eq(["john@aol.com"]) mail.body.decoded.should include "Error" end
并且代码应该使用满足块中指定条件的参数调用给定对象的方法send_mail.
本文共计241个文字,预计阅读时间需要1分钟。
是否可以检查传递给方法调用的参数是否符合某些约束。我想做的是 +my_double=double(MyObject) my_double.should_receive(:mocked_method).with { something that has an attribute called name and value john } 非常正常。
my_double = double("MyObject") my_double.should_receive(:mocked_method).with{ <something that has an attribute called name and value "john"> }
非常感谢提前.
编辑:我会尝试澄清一下我想要完成的事情
我想要的是检查模拟的给定方法是否被调用传递满足某些条件的对象
作为记录.我想要完成的是什么@test_double.should_receive(:send_mail) do |mail| mail.to.should eq(["john@aol.com"]) mail.body.decoded.should include "Error" end
并且代码应该使用满足块中指定条件的参数调用给定对象的方法send_mail.

