seattlerb/minitest — pull request #375 by petergoldstein (2013-12-05 22:48:01+00:00)
Title: Mock objects should respond to equal?

Currently equal? is being undefined on mock objects, meaning that mocks can't compare identity.

equal? should not be undefined because it should essentially never be overridden by subclasses, as opposed to '==' which is commonly overridden. Undefining this method causes surprising and undesirable behavior on Rubinius, as it explicitly uses the equal? method for comparing object identities (as opposed to a pointer comparison shortcut which is used by MRI and now JRuby as of 1.7.9).

An example of a spec that fails on Rubinius is:

it 'computes equality when using arrays containing Mintest::Mock objects' do
item = Minitest::Mock.new
item_array = [item]
other_item_array = [item]
assert_equal item_array, other_item_array
end

In this circumstance I don't see any reason why we should require the developer to mock 'equal?' or '==' on the item.

Note that this is not a hypothetical case - the Rubinius specs for Sidekiq are failing for precisely this reason, as can be seen here - https://travis-ci.org/mperham/sidekiq/jobs/14995491