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
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/minitest/assertions.rb', line 216 def assert_equal exp, act, msg = nil msg = (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 where = Minitest.filter_backtrace(caller).first where = where.split(/:in /, 2).first # clean up noise warn "DEPRECATED: Use assert_nil if expecting nil from #{where}. This will fail in Minitest 6." end end result end |