Method: Minitest::Assertions#assert_equal

Defined in:
lib/minitest/assertions.rb

#assert_equal(exp, act, msg = nil) ⇒ Object

Fails unless exp == act printing the difference between the two, if possible.

If there is no visible difference but the assertion fails, you should suspect that your #== is buggy, or your inspect output is missing crucial details. For nicer structural diffing, set Minitest::Test.make_my_diffs_pretty!

For floats use assert_in_delta.

See also: Minitest::Assertions.diff



221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/minitest/assertions.rb', line 221

def assert_equal exp, act, msg = nil
  msg = message(msg, E) { diff exp, act }
  result = assert exp == act, msg

  if nil == exp then
    if Minitest::VERSION =~ /^6/ then
      refute_nil exp, "Use assert_nil if expecting nil."
    else
      warn "DEPRECATED: Use assert_nil if expecting nil from #{_where}. This will fail in Minitest 6."
    end
  end

  result
end