[rspec-users] array order-agnostic matching?

James OBrien james at rapleaf.com
Tue Feb 1 04:40:52 EST 2011

hey, thanks for reading:

I have a problem which can be reduced to this,

from within an example of mine I call the helper 'expect_call' which is
defined thus:

def expect_call(*hash*)*

and in one of my examples the 'expected' hash is strictly defined as follows

   :some_key => [1,2,3]

however my spec fails because it is actually called with

   :some_key => [1,3,2]

*or maybe

   :some_key => [2,3,1]


   :some_key => [2,1,3]

*i.e. the array part is not in the order i 'expect' BUT i don't actually
care about the order. So I would like to be able to change my one example to
something like this:

   *:some_key => [1,2,3]*.ignoring_order

does such a concept exist or do I have to change the implementation of
expect_call to use some sort of custom matcher - I am reluctant to do this
since this method is called in other cases where maybe (for arguments sake)
I DO care about array ordering within the hash.

Hope someone can solve this for me - MUCH appreciation.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110201/0be56c69/attachment-0001.html>

More information about the rspec-users mailing list