So I am learning Ruby through ruby koans tutorial.
In the about_assert.rb script, there is a comment regarding assert_equal,
“Some ways of asserting equality are better than others”
here is the code
def test_a_better_way_of_asserting_equality
expected_value = 2
actual_value = 1 + 1
assert_equal expected_value, actual_value
end
my question is , why
assert_equal expected_value, actual_value is better than
assert expected_value == actual_value
I myself use Rspec, so I don’t know for sure.
But I’d guess that the difference is with the message you get when assertion fails.
In
assert_equalyou should get something like “Expected value to be X, got Y”.And in the other case you’ll get just something like “Assertion failed”.
You can do a quick test and verify or disprove my point 🙂