Method: Test::Unit::Assertions#assert_equal
- Defined in:
- lib/test/unit/assertions.rb
#assert_equal(expected, actual, message = nil) ⇒ Object
Passes if expected
== actual
.
Note that the ordering of arguments is important, since a helpful error message is generated when this one fails that tells you the values of expected and actual.
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'lib/test/unit/assertions.rb', line 225 def assert_equal(expected, actual, =nil) diff = AssertionMessage.delayed_diff(expected, actual) if expected.respond_to?(:encoding) and actual.respond_to?(:encoding) and expected.encoding != actual.encoding format = <<EOT <?>(?) expected but was <?>(?).? EOT = (, format, expected, expected.encoding.name, actual, actual.encoding.name, diff) else = (, <<EOT, expected, actual, diff) <?> expected but was <?>.? EOT end begin assert_block() { expected == actual } rescue AssertionFailedError => failure _set_failed_information(failure, expected, actual) raise failure # For JRuby. :< end end |