title: Does an RSpec2 matcher for matching Hashes exist?
body: <p>Note to future readers: think RSpec does not consider your Hashes equal? One might be an OrderedHash, but from the regular RSpec output you can't tell. This was the problem that prompted this post.</p>
  
  <p>Original question:</p>
  
  <p>Suppose I have a spec where I want to test that a method generates the appropriate Hash.</p>
  
  <pre><code>it 'should generate the Hash correctly' do
    expected = {:foo =&gt; 1, 'baz' =&gt; 2}
    subject.some_method_that_should_generate_the_hash.should == expected
  end
  </code></pre>
  
  <p>This often fails, because different Hashes with the same key-value pairs may return their pairs in a different ordered. Results look like:</p>
  
  <pre><code>Failure/Error: subject.some_method_that_should_generate_the_hash.should == expected
  expected: {:foo =&gt; 1, 'baz' =&gt; 2},
       got: {'baz' =&gt; 2, :foo =&gt; 1}
  </code></pre>
  
  <p>For arrays, this is solved using the =~ operator. However, that does not work for Hashes. For now, I've resorted to </p>
  
  <pre><code>it 'should generate the Hash correctly' do
    expected = {:foo =&gt; 1, 'baz' =&gt; 2}
    subject.some_method_that_should_generate_the_hash.each {|k,v|
      v.should == expected[k]
    }
  end
  </code></pre>
  
  <p>but that seems unnecessarily verbose. I expect there to be an obvious solution for this. Am I overlooking something in the docs or doesn't RSpec have a proper Matcher for orderless Hash equality?</p>