Does an RSpec2 matcher for matching Hashes exist?

前端 未结 3 2256
渐次进展
渐次进展 2021-02-12 23:10

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 tha

3条回答
  •  野的像风
    2021-02-12 23:38

    I believe the eql? method checks only that the two hashes have the same content So IIRC in Rspec2 you can do:

        expected = {:foo => 1, 'baz' => 2}
        expected.should be_eql({'baz' => 2, :foo => 1})
    

    And the test should pass

提交回复
热议问题