money 6.9.0 → 6.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +131 -3
- data/LICENSE +17 -17
- data/README.md +181 -71
- data/config/currency_backwards_compatible.json +65 -0
- data/config/currency_iso.json +119 -56
- data/config/currency_non_iso.json +35 -2
- data/lib/money/bank/variable_exchange.rb +22 -12
- data/lib/money/currency/loader.rb +15 -13
- data/lib/money/currency.rb +38 -39
- data/lib/money/locale_backend/base.rb +7 -0
- data/lib/money/locale_backend/currency.rb +11 -0
- data/lib/money/locale_backend/errors.rb +6 -0
- data/lib/money/locale_backend/i18n.rb +25 -0
- data/lib/money/locale_backend/legacy.rb +28 -0
- data/lib/money/money/allocation.rb +46 -0
- data/lib/money/money/arithmetic.rb +33 -15
- data/lib/money/money/constructors.rb +1 -2
- data/lib/money/money/formatter.rb +399 -0
- data/lib/money/money/formatting_rules.rb +142 -0
- data/lib/money/money/locale_backend.rb +22 -0
- data/lib/money/money.rb +235 -187
- data/lib/money/rates_store/memory.rb +24 -24
- data/lib/money/version.rb +1 -1
- data/money.gemspec +14 -8
- metadata +36 -56
- data/.coveralls.yml +0 -1
- data/.gitignore +0 -23
- data/.rspec +0 -1
- data/.travis.yml +0 -26
- data/AUTHORS +0 -126
- data/CONTRIBUTING.md +0 -17
- data/Gemfile +0 -16
- data/Rakefile +0 -17
- data/lib/money/money/formatting.rb +0 -426
- data/spec/bank/base_spec.rb +0 -79
- data/spec/bank/single_currency_spec.rb +0 -13
- data/spec/bank/variable_exchange_spec.rb +0 -265
- data/spec/currency/heuristics_spec.rb +0 -11
- data/spec/currency/loader_spec.rb +0 -19
- data/spec/currency_spec.rb +0 -359
- data/spec/money/arithmetic_spec.rb +0 -693
- data/spec/money/constructors_spec.rb +0 -103
- data/spec/money/formatting_spec.rb +0 -757
- data/spec/money_spec.rb +0 -778
- data/spec/rates_store/memory_spec.rb +0 -69
- data/spec/spec_helper.rb +0 -28
@@ -1,103 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
describe Money::Constructors do
|
4
|
-
|
5
|
-
describe "::empty" do
|
6
|
-
it "creates a new Money object of 0 cents" do
|
7
|
-
expect(Money.empty).to eq Money.new(0)
|
8
|
-
end
|
9
|
-
|
10
|
-
it "memoizes the result" do
|
11
|
-
expect(Money.empty.object_id).to eq Money.empty.object_id
|
12
|
-
end
|
13
|
-
|
14
|
-
it "memoizes a result for each currency" do
|
15
|
-
expect(Money.empty(:cad).object_id).to eq Money.empty(:cad).object_id
|
16
|
-
end
|
17
|
-
|
18
|
-
it "doesn't allow money to be modified for a currency" do
|
19
|
-
expect(Money.empty).to be_frozen
|
20
|
-
end
|
21
|
-
|
22
|
-
it "instantiates a subclass when inheritance is used" do
|
23
|
-
special_money_class = Class.new(Money)
|
24
|
-
expect(special_money_class.empty).to be_a special_money_class
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
describe "::zero" do
|
30
|
-
subject { Money.zero }
|
31
|
-
it { is_expected.to eq Money.empty }
|
32
|
-
|
33
|
-
it "instantiates a subclass when inheritance is used" do
|
34
|
-
special_money_class = Class.new(Money)
|
35
|
-
expect(special_money_class.zero).to be_a special_money_class
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
describe "::ca_dollar" do
|
41
|
-
it "creates a new Money object of the given value in CAD" do
|
42
|
-
expect(Money.ca_dollar(50)).to eq Money.new(50, "CAD")
|
43
|
-
end
|
44
|
-
|
45
|
-
it "is aliased to ::cad" do
|
46
|
-
expect(Money.cad(50)).to eq Money.ca_dollar(50)
|
47
|
-
end
|
48
|
-
|
49
|
-
it "instantiates a subclass when inheritance is used" do
|
50
|
-
special_money_class = Class.new(Money)
|
51
|
-
expect(special_money_class.ca_dollar(0)).to be_a special_money_class
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
|
56
|
-
describe "::us_dollar" do
|
57
|
-
it "creates a new Money object of the given value in USD" do
|
58
|
-
expect(Money.us_dollar(50)).to eq Money.new(50, "USD")
|
59
|
-
end
|
60
|
-
|
61
|
-
it "is aliased to ::usd" do
|
62
|
-
expect(Money.usd(50)).to eq Money.us_dollar(50)
|
63
|
-
end
|
64
|
-
|
65
|
-
it "instantiates a subclass when inheritance is used" do
|
66
|
-
special_money_class = Class.new(Money)
|
67
|
-
expect(special_money_class.us_dollar(0)).to be_a special_money_class
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
describe "::euro" do
|
73
|
-
it "creates a new Money object of the given value in EUR" do
|
74
|
-
expect(Money.euro(50)).to eq Money.new(50, "EUR")
|
75
|
-
end
|
76
|
-
|
77
|
-
it "is aliased to ::eur" do
|
78
|
-
expect(Money.eur(50)).to eq Money.euro(50)
|
79
|
-
end
|
80
|
-
|
81
|
-
it "instantiates a subclass when inheritance is used" do
|
82
|
-
special_money_class = Class.new(Money)
|
83
|
-
expect(special_money_class.euro(0)).to be_a special_money_class
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
|
88
|
-
describe "::pound_sterling" do
|
89
|
-
it "creates a new Money object of the given value in GBP" do
|
90
|
-
expect(Money.pound_sterling(50)).to eq Money.new(50, "GBP")
|
91
|
-
end
|
92
|
-
|
93
|
-
it "is aliased to ::gbp" do
|
94
|
-
expect(Money.gbp(50)).to eq Money.pound_sterling(50)
|
95
|
-
end
|
96
|
-
|
97
|
-
it "instantiates a subclass when inheritance is used" do
|
98
|
-
special_money_class = Class.new(Money)
|
99
|
-
expect(special_money_class.pound_sterling(0)).to be_a special_money_class
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
end
|