请告诉我如何检查should_receive中的返回对象是否是ClassName的实例。
Messaging.should_receive(:send_text).with(:foo, :bar, object)
Rails 3
答案 0 :(得分:1)
答案是: Messaging.should_receive(:send_text).with(:foo,:bar,kind_of(ClassName))
编辑:正确答案是:
Messaging.should_receive(:send_text).with(:foo, :bar, instance_of(ClassName))
感谢K M Rakibul Islam
答案 1 :(得分:1)
如果您想让它接收特定类的实例,那么可以使用instance_of
:
Messaging.should_receive(:send_text).with(:foo, :bar, instance_of(ClassName))