Money library error in substraction
February 12th, 2006
The Money library is a useful. Unfortunately, release 1.5.9 has an error. One cannot substract an amount from the empty Money.
1 2 3 |
def test_substract_from_zero assert_equal -12.to_money, Money.empty - (12.to_money) end |
1) Failure:
test_substract_from_zero(MoneyTest) [./test/unit/money_test.rb:29]:
<#> expected but was
<#>.
The error is caused by Money#-(other_money):
1 2 3 4 |
def -(other_money) return other_money.dup if cents.zero? ... end |
return other_money.dup if cents.zero? should be removed to allow the test case to pass.
Update (2006-02-13): Tobias already posted a new version of the library, available as a gem.