Rspec matcher by array argument similar to hash_including

In rspec, you can verify that a method call receives an argument, which is a hash, and includes certain keys or key-value pairs. I.e:

my_object.should_receive(:my_method).with(hash_including(:a => 'alpha')) 

Is there anything available to do a similar match with an array? Anything that will look like?

 my_object.should_receive(:my_method).with(array_including('alpha')) 
+4
source share
1 answer

How about this:

 my_obj.should_receive(:my_method) do |arg| arg.should be_an_instance_of(Array) arg.should include('alpha') end 
+6
source

All Articles