[rspec-users] hash_include with regular expression

mikev mike.vogel at emc.com
Tue Feb 16 08:09:04 EST 2010


I'm trying to match a string in a hash passed to :find using a regular
expression since I don't want to know all the other details of
the :conditions passed to find.  I've tried variations on the
following with no success, e.g., not using hash_including and putting
both hashes into a single hash_include.

c = /.*a.snapshot_id = 1.*/
SomeClass.should_receive(:find).with(:all,
hash_including(:conditions=>c),
hash_including(:include=>'')).and_return([mock_class])

The rspec fails with the following:
  expected: (:all, hash_including(:conditions=>/.*da.snapshot_id =
1.*/),
                            hash_including(:include=>""))
   got: (:all, {:conditions=>" a.snapshot_id = 1 OTHER CRITERIA...
", :include=>""})


More information about the rspec-users mailing list