Ruby/Git: work with Git from Ruby
2008-02-01
The Money library is a useful. Unfortunately, release 1.5.9 has an error. One cannot substract an amount from the empty Money.
1 def test_substract_from_zero
2 assert_equal -12.to_money, Money.empty – (12.to_money)
3 end
The test case will fail with this:
1 1) Failure:
2 test_substract_from_zero(MoneyTest) [./test/unit/money_test.rb:29]:
3 <#<Money:0×3accb68 @cents=-1200, @currency="USD">> expected but was
4 <#<Money:0×3acca60 @cents=1200, @currency="USD">>.
The error is caused by Money#-(other_money):
1 def -(other_money)
2 return other_money.dup if cents.zero?
3 …
4 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.
I am François Beausoleil, a Ruby on Rails and Scala developer. During the day, I work on Seevibes, a platform to measure social interactions related to TV shows. At night, I am interested many things. Read my biography.