You can use any RSpec matcher to match arguments of method calls

Updated . Posted . Visible to the public.

RSpec lets you define the arguments with which you expect a method to be invoked:

subject.should_receive(:say).with('hello')

Sometimes you don't care about the exact arguments. For such cases RSpec comes with argument constraints Show archive.org snapshot like anything or hash_including:

subject.should_receive(:update_attributes).with(hash_including(:message => 'hi world'))

You can go even further and use any RSpec matcher to match arguments:

subject.should_receive(:say).with(instance_of(String))
Henning Koch
Last edit
Henning Koch
Keywords
kind_of, instance
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2011-10-17 14:01)