Forum: Ruby on Rails Money library error

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3dd4b52a0946bd698b1d1635a46ea3a3?d=identicon&s=25 Francois Beausoleil (Guest)
on 2006-02-13 09:30
(Received via mailing list)
Hello everyone !

The following test fails:

def test_substract_from_zero
  assert_equal -12.to_money, Money.empty - (12.to_money)
end

This is equivalent to the normal arithmetic expression: 0 - 12 == -12.

The error is caused by the first line of Money#-(other_money)

def -(other_money)
  return other_money.dup if cents.zero?
  ...
end

"return other_money.dup if cents.zero?" should be removed to pass the
test case.

This is also on my blog.

Hope that helps someone !
This topic is locked and can not be replied to.