more_money 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
+ 0.0.10 fixed bug in comparing nil objects with <=>
1
2
  0.0.9 fixed bug in to_s now if cents are nil to_s returns ''
2
3
  0.0.8 fixed the bug that was parsing invalid strings in 0 cents now maps to nil
3
4
  0.0.7 introduced MoreMoney::Money.curr_symbol
@@ -141,11 +141,10 @@ module MoreMoney
141
141
 
142
142
  def <=>(other_money)
143
143
  if cents == nil
144
- return true if other_money.cents == nil
144
+ return 0 if other_money.cents == nil
145
+ return -1
145
146
  elsif currency == other_money.currency
146
- return 0 <=> other_money.cents if cents == nil
147
- return cents <=> 0 if other_money.cents == nil
148
-
147
+ return 1 if other_money.cents == nil
149
148
  cents <=> other_money.cents
150
149
  else
151
150
  cents <=> other_money.exchange_to(currency).cents
@@ -2,7 +2,7 @@ module MoreMoney #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 9
5
+ TINY = 10
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -93,6 +93,20 @@ class MoreMoneyTest < Test::Unit::TestCase
93
93
  assert_equal nil, a.cents
94
94
  end
95
95
 
96
+ def test_nil_comparable
97
+ a = Money.new(nil)
98
+ b = Money.new(nil)
99
+ c = Money.new(0)
100
+ d = Money.new(0)
101
+ assert_equal true, (a == b)
102
+ assert_equal false, (a != b)
103
+ assert_equal true, (c == d)
104
+ assert_equal false, (c != d)
105
+ assert_equal false, (a == c)
106
+ assert_equal true, (c != a)
107
+ assert_equal true, (c > a)
108
+ end
109
+
96
110
  def test_symbol
97
111
  assert_equal '$', Money.curr_symbol
98
112
  assert_equal '£', Money.curr_symbol('GBP')
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: more_money
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.9
7
- date: 2007-02-13 00:00:00 +00:00
6
+ version: 0.0.10
7
+ date: 2007-02-14 00:00:00 +00:00
8
8
  summary: handles money objects in any currency using just integer as backend
9
9
  require_paths:
10
10
  - lib