在rspec中,您可以测试对方法的调用是否接收到作为哈希的参数,并包含某些键或键值对.那是:
my_object.should_receive(:my_method).with(hash_including(:a => 'alpha'))
Run Code Online (Sandbox Code Playgroud)
有没有什么可以用数组完成类似的匹配?看起来像什么?
my_object.should_receive(:my_method).with(array_including('alpha'))
Run Code Online (Sandbox Code Playgroud)