我有一个获取信息的方法。
module MyModule
extend self
def my_method(a)
puts a
end
end
我想确保该方法接收到一个键
:a, :b and :c
MyModule.should_receive(:method).with(A_HASH_WITH_KEYS(:a,:b,:c))
calling the method
最佳答案
您可以将hash_including
与anyhting
结合使用:
MyModule.should_receive(:method).with(
hash_including(a: anything,b: anything,c: anything))
编辑
似乎
hash_including
API的newer versions接受密钥数组,因此这也应该有效:MyModule.should_receive(:method).with(hash_including(:a, :b, :c))