I have the following Rspec test:
it 'creates an initial version with all the versionable attributes' do resource = create(:versionable_resource) version_attributes = resource.initial_version.new_attributes.sort expect(version_attributes).to eq(resource.versionable_attributes.sort) end Both version_attributes and resource.versionable_attributes are hashes. They have the exact same contents. However, the eq statement is failing with:
expected: [["r_boolean", true], ["r_date", Sun, 26 Jan 2014], ["r_datetime", Sun, 26 Jan 2014 23:00:56 UTC +00:00], ["r_float", 3.14], ["r_integer", 3], ["r_string", "my string"], ["r_text", "my text"], ["r_time", 2014-01-26 17:00:56 -0600]] got: [["r_boolean", true], ["r_date", Sun, 26 Jan 2014], ["r_datetime", Sun, 26 Jan 2014 23:00:56 UTC +00:00], ["r_float", 3.14], ["r_integer", 3], ["r_string", "my string"], ["r_text", "my text"], ["r_time", 2014-01-26 17:00:56 -0600]] (compared using ==) As you can see, the contents are identical. Why is this failing? Should I use a different matcher than eq? I've tried eql and equal as well, and all fail the same way.