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
The test case will fail with this:
  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.

 

Search

A picture of me

I am François Beausoleil, a Ruby on Rails coder. During the day, I work on XLsuite. At night, I am interested many things. Read my biography

Tags

(3) (1) (0) (2) (1) (1) (2) (2) (1) (2) (1) (2) (1) (2) (1) (1) (1) (1) (2) (14) (1) (1) (1) (1) (2) (1) (1) (2) (0) (1) (2) (1) (3) (1) (1) (1) (1) (1) (1) (0) (3) (2) (1) (2) (2) (1) (3) (2) (8) (8) (9) (12) (1) (1) (3) (1) (1) (1) (1) (1) (1) (2) (2) (2) (1) (1) (3) (1) (3) (1) (0) (23) (1) (1) (0) (1) (1) (1) (23) (25) (1) (1) (13) (1) (1) (2) (3) (1) (1) (4) (1) (2) (3) (0) (1) (7) (3) (1) (5) (5) (2) (2) (2) (4) (6) (7) (1) (0) (1) (1) (2) (2) (1) (4) (12) (2) (1) (2) (4) (1) (1) (1) (2) (8) (2) (3) (2) (2) (1) (3) (1) (1)

Links

Projects I work on

Categories

Archives