money_helper 0.0.5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/money_helper.rb +3 -2
- data/spec/money_helper_spec.rb +129 -129
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZWIyMmI3OTU3NmUxMjQ2OTBhMDMwMWE3OGI0YTZmYWNlMWIxM2I5MA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MGFjMWQ5MTRlMzVkYWRjMTA0ZGI1NDQxNjk3NzUzNDRjZWEzM2ZmOA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OWIzN2QxZDUwOTMyNWFiMTZmZTdhNzIwZDMwZDBkMmJmMWMzMjQ5YjNiMGE4
|
10
|
+
YzgxYWRlN2YyMGYyODJkNDI4NmI4ZjliZmM4MTM0ZTMzYTc1MWRjOWFlOTE4
|
11
|
+
YmJiY2NiMmU4YzFhM2JlNjM0M2EyYzE2ZGI3MmIzY2YwOGQ3MDA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTVkOWYyZDMzOWM1NmY5NDc1MTRlYmFkNDIwNjk3N2VkNDUwNDI5YWZkZGVi
|
14
|
+
NTAzM2ZhYmQzZWJmNDA3YTllYTg5ZTg1MDcwYjQ0ZmY2MjJlMmI2MGEyMTFj
|
15
|
+
M2NlMjllZDczMDgxZWE2NDhiMzMwYTc0MGZmMzYxMzlhYTUzMDU=
|
data/lib/money_helper.rb
CHANGED
@@ -4,10 +4,11 @@ require 'active_support/core_ext/object/blank'
|
|
4
4
|
require 'money'
|
5
5
|
|
6
6
|
module MoneyHelper
|
7
|
+
I18n.enforce_available_locales = false
|
7
8
|
|
8
|
-
SYMBOL_ONLY = %w{USD GBP EUR MYR
|
9
|
+
SYMBOL_ONLY = %w{USD GBP EUR MYR} #don't use ISO code
|
9
10
|
OK_SYMBOLS = %w{
|
10
|
-
$ £ € ¥ 元 р. L ƒ ৳ P R$ K ₡ D ლ ₵ Q G ₹ Rp ₪ ₩ ₭ R RM ₨ ₮ դր. C$ ₦
|
11
|
+
$ £ € ¥ 元 р. L ƒ ৳ P R$ K ₡ D ლ ₵ Q G ₹ Rp ₪ ₩ ₭ R RM ₨ ₮ դր. C$ ₦ ₲ ₱ T ฿ T$ m ₴ ₫ ៛ ₺ E ₽
|
11
12
|
} #ok to include in string
|
12
13
|
|
13
14
|
##
|
data/spec/money_helper_spec.rb
CHANGED
@@ -5,174 +5,174 @@ require 'money_helper'
|
|
5
5
|
describe MoneyHelper do
|
6
6
|
describe "money_to_text" do
|
7
7
|
it "includes only symbol for well-recognizable currencies" do
|
8
|
-
MoneyHelper.money_to_text(30000, "EUR").
|
9
|
-
MoneyHelper.money_to_text(30000, "GBP").
|
10
|
-
MoneyHelper.money_to_text(30000, "MYR").
|
11
|
-
MoneyHelper.money_to_text(30000, "TRY").
|
12
|
-
MoneyHelper.money_to_text(30000, "USD").
|
8
|
+
expect(MoneyHelper.money_to_text(30000, "EUR")).to eql("€30.000")
|
9
|
+
expect(MoneyHelper.money_to_text(30000, "GBP")).to eql("£30,000")
|
10
|
+
expect(MoneyHelper.money_to_text(30000, "MYR")).to eql("RM30,000")
|
11
|
+
expect(MoneyHelper.money_to_text(30000, "TRY")).to eql("TRY ₺30.000")
|
12
|
+
expect(MoneyHelper.money_to_text(30000, "USD")).to eql("$30,000")
|
13
13
|
end
|
14
14
|
it "includes ISO code and symbol for ambiguous currencies" do
|
15
|
-
MoneyHelper.money_to_text(30000, "AUD").
|
16
|
-
MoneyHelper.money_to_text(30000, "ARS").
|
17
|
-
MoneyHelper.money_to_text(30000, "BBD").
|
18
|
-
MoneyHelper.money_to_text(30000, "BMD").
|
19
|
-
MoneyHelper.money_to_text(30000, "BND").
|
20
|
-
MoneyHelper.money_to_text(30000, "BSD").
|
21
|
-
MoneyHelper.money_to_text(30000, "BZD").
|
22
|
-
MoneyHelper.money_to_text(30000, "CAD").
|
23
|
-
MoneyHelper.money_to_text(30000, "CLP").
|
24
|
-
MoneyHelper.money_to_text(30000, "COP").
|
25
|
-
MoneyHelper.money_to_text(30000, "CUC").
|
26
|
-
MoneyHelper.money_to_text(30000, "CUP").
|
27
|
-
MoneyHelper.money_to_text(30000, "DOP").
|
28
|
-
MoneyHelper.money_to_text(30000, "FJD").
|
29
|
-
MoneyHelper.money_to_text(30000, "GYD").
|
30
|
-
MoneyHelper.money_to_text(30000, "HKD").
|
31
|
-
MoneyHelper.money_to_text(30000, "JMD").
|
32
|
-
MoneyHelper.money_to_text(30000, "KYD").
|
33
|
-
MoneyHelper.money_to_text(30000, "LRD").
|
34
|
-
MoneyHelper.money_to_text(30000, "MXN").
|
35
|
-
MoneyHelper.money_to_text(30000, "NAD").
|
36
|
-
MoneyHelper.money_to_text(30000, "NZD").
|
37
|
-
MoneyHelper.money_to_text(30000, "SBD").
|
38
|
-
MoneyHelper.money_to_text(30000, "SGD").
|
39
|
-
MoneyHelper.money_to_text(30000, "SRD").
|
40
|
-
MoneyHelper.money_to_text(30000, "TWD").
|
41
|
-
MoneyHelper.money_to_text(30000, "TTD").
|
42
|
-
MoneyHelper.money_to_text(30000, "UYU").
|
43
|
-
MoneyHelper.money_to_text(30000, "XCD").
|
44
|
-
MoneyHelper.money_to_text(30000, "ZWL").
|
15
|
+
expect(MoneyHelper.money_to_text(30000, "AUD")).to eql("AUD $30,000")
|
16
|
+
expect(MoneyHelper.money_to_text(30000, "ARS")).to eql("ARS $30.000")
|
17
|
+
expect(MoneyHelper.money_to_text(30000, "BBD")).to eql("BBD $30,000")
|
18
|
+
expect(MoneyHelper.money_to_text(30000, "BMD")).to eql("BMD $30,000")
|
19
|
+
expect(MoneyHelper.money_to_text(30000, "BND")).to eql("BND $30,000")
|
20
|
+
expect(MoneyHelper.money_to_text(30000, "BSD")).to eql("BSD $30,000")
|
21
|
+
expect(MoneyHelper.money_to_text(30000, "BZD")).to eql("BZD $30,000")
|
22
|
+
expect(MoneyHelper.money_to_text(30000, "CAD")).to eql("CAD $30,000")
|
23
|
+
expect(MoneyHelper.money_to_text(30000, "CLP")).to eql("CLP $30.000")
|
24
|
+
expect(MoneyHelper.money_to_text(30000, "COP")).to eql("COP $30.000")
|
25
|
+
expect(MoneyHelper.money_to_text(30000, "CUC")).to eql("CUC $30,000")
|
26
|
+
expect(MoneyHelper.money_to_text(30000, "CUP")).to eql("CUP $30,000")
|
27
|
+
expect(MoneyHelper.money_to_text(30000, "DOP")).to eql("DOP $30,000")
|
28
|
+
expect(MoneyHelper.money_to_text(30000, "FJD")).to eql("FJD $30,000")
|
29
|
+
expect(MoneyHelper.money_to_text(30000, "GYD")).to eql("GYD $30,000")
|
30
|
+
expect(MoneyHelper.money_to_text(30000, "HKD")).to eql("HKD $30,000")
|
31
|
+
expect(MoneyHelper.money_to_text(30000, "JMD")).to eql("JMD $30,000")
|
32
|
+
expect(MoneyHelper.money_to_text(30000, "KYD")).to eql("KYD $30,000")
|
33
|
+
expect(MoneyHelper.money_to_text(30000, "LRD")).to eql("LRD $30,000")
|
34
|
+
expect(MoneyHelper.money_to_text(30000, "MXN")).to eql("MXN $30,000")
|
35
|
+
expect(MoneyHelper.money_to_text(30000, "NAD")).to eql("NAD $30,000")
|
36
|
+
expect(MoneyHelper.money_to_text(30000, "NZD")).to eql("NZD $30,000")
|
37
|
+
expect(MoneyHelper.money_to_text(30000, "SBD")).to eql("SBD $30,000")
|
38
|
+
expect(MoneyHelper.money_to_text(30000, "SGD")).to eql("SGD $30,000")
|
39
|
+
expect(MoneyHelper.money_to_text(30000, "SRD")).to eql("SRD $30,000")
|
40
|
+
expect(MoneyHelper.money_to_text(30000, "TWD")).to eql("TWD $30,000")
|
41
|
+
expect(MoneyHelper.money_to_text(30000, "TTD")).to eql("TTD $30,000")
|
42
|
+
expect(MoneyHelper.money_to_text(30000, "UYU")).to eql("UYU $30.000")
|
43
|
+
expect(MoneyHelper.money_to_text(30000, "XCD")).to eql("XCD $30,000")
|
44
|
+
expect(MoneyHelper.money_to_text(30000, "ZWL")).to eql("ZWL $30,000")
|
45
45
|
|
46
|
-
MoneyHelper.money_to_text(30000, "FKP").
|
47
|
-
MoneyHelper.money_to_text(30000, "GIP").
|
48
|
-
MoneyHelper.money_to_text(30000, "SDG").
|
49
|
-
MoneyHelper.money_to_text(30000, "SHP").
|
46
|
+
expect(MoneyHelper.money_to_text(30000, "FKP")).to eql("FKP £30,000")
|
47
|
+
expect(MoneyHelper.money_to_text(30000, "GIP")).to eql("GIP £30,000")
|
48
|
+
expect(MoneyHelper.money_to_text(30000, "SDG")).to eql("SDG £30,000")
|
49
|
+
expect(MoneyHelper.money_to_text(30000, "SHP")).to eql("SHP £30,000")
|
50
50
|
|
51
|
-
MoneyHelper.money_to_text(30000, "CNY").
|
52
|
-
MoneyHelper.money_to_text(30000, "JPY").
|
51
|
+
expect(MoneyHelper.money_to_text(30000, "CNY")).to eql("CNY ¥30,000")
|
52
|
+
expect(MoneyHelper.money_to_text(30000, "JPY")).to eql("JPY ¥30,000")
|
53
53
|
|
54
|
-
MoneyHelper.money_to_text(30000, "ALL").
|
55
|
-
MoneyHelper.money_to_text(30000, "HNL").
|
56
|
-
MoneyHelper.money_to_text(30000, "LSL").
|
57
|
-
MoneyHelper.money_to_text(30000, "MDL").
|
58
|
-
MoneyHelper.money_to_text(30000, "RON").
|
59
|
-
MoneyHelper.money_to_text(30000, "SZL").
|
54
|
+
expect(MoneyHelper.money_to_text(30000, "ALL")).to eql("ALL L30,000")
|
55
|
+
expect(MoneyHelper.money_to_text(30000, "HNL")).to eql("HNL L30,000")
|
56
|
+
expect(MoneyHelper.money_to_text(30000, "LSL")).to eql("LSL L30,000")
|
57
|
+
expect(MoneyHelper.money_to_text(30000, "MDL")).to eql("MDL L30,000")
|
58
|
+
expect(MoneyHelper.money_to_text(30000, "RON")).to eql("RON 30.000")
|
59
|
+
expect(MoneyHelper.money_to_text(30000, "SZL")).to eql("SZL E30,000")
|
60
60
|
|
61
|
-
MoneyHelper.money_to_text(30000, "ANG").
|
62
|
-
MoneyHelper.money_to_text(30000, "AWG").
|
61
|
+
expect(MoneyHelper.money_to_text(30000, "ANG")).to eql("ANG ƒ30.000")
|
62
|
+
expect(MoneyHelper.money_to_text(30000, "AWG")).to eql("AWG ƒ30,000")
|
63
63
|
|
64
|
-
MoneyHelper.money_to_text(30000, "BWP").
|
65
|
-
MoneyHelper.money_to_text(30000, "MOP").
|
64
|
+
expect(MoneyHelper.money_to_text(30000, "BWP")).to eql("BWP P30,000")
|
65
|
+
expect(MoneyHelper.money_to_text(30000, "MOP")).to eql("MOP P30,000")
|
66
66
|
|
67
|
-
MoneyHelper.money_to_text(30000, "CRC").
|
68
|
-
MoneyHelper.money_to_text(30000, "SVC").
|
67
|
+
expect(MoneyHelper.money_to_text(30000, "CRC")).to eql("CRC ₡30.000")
|
68
|
+
expect(MoneyHelper.money_to_text(30000, "SVC")).to eql("SVC ₡30,000")
|
69
69
|
|
70
|
-
MoneyHelper.money_to_text(30000, "MUR").
|
71
|
-
MoneyHelper.money_to_text(30000, "NPR").
|
72
|
-
MoneyHelper.money_to_text(30000, "PKR").
|
73
|
-
MoneyHelper.money_to_text(30000, "SCR").
|
70
|
+
expect(MoneyHelper.money_to_text(30000, "MUR")).to eql("MUR ₨30,000")
|
71
|
+
expect(MoneyHelper.money_to_text(30000, "NPR")).to eql("NPR ₨30,000")
|
72
|
+
expect(MoneyHelper.money_to_text(30000, "PKR")).to eql("PKR ₨30,000")
|
73
|
+
expect(MoneyHelper.money_to_text(30000, "SCR")).to eql("SCR ₨30,000")
|
74
74
|
end
|
75
75
|
it "includes ISO code and symbol for difficult to recognize symbols" do
|
76
|
-
MoneyHelper.money_to_text(30000, "AMD").
|
77
|
-
MoneyHelper.money_to_text(30000, "BDT").
|
78
|
-
MoneyHelper.money_to_text(30000, "BRL").
|
79
|
-
MoneyHelper.money_to_text(30000, "GMD").
|
80
|
-
MoneyHelper.money_to_text(30000, "GEL").
|
81
|
-
MoneyHelper.money_to_text(30000, "GHS").
|
82
|
-
MoneyHelper.money_to_text(30000, "GTQ").
|
83
|
-
MoneyHelper.money_to_text(30000, "HTG").
|
84
|
-
MoneyHelper.money_to_text(30000, "IDR").
|
85
|
-
MoneyHelper.money_to_text(30000, "ILS").
|
86
|
-
MoneyHelper.money_to_text(30000, "INR").
|
87
|
-
MoneyHelper.money_to_text(30000, "KHR").
|
88
|
-
MoneyHelper.money_to_text(30000, "KPW").
|
89
|
-
MoneyHelper.money_to_text(30000, "LAK").
|
90
|
-
MoneyHelper.money_to_text(30000, "MNT").
|
91
|
-
MoneyHelper.money_to_text(30000, "NIO").
|
92
|
-
MoneyHelper.money_to_text(30000, "NGN").
|
93
|
-
MoneyHelper.money_to_text(30000, "PGK").
|
94
|
-
MoneyHelper.money_to_text(30000, "PHP").
|
95
|
-
MoneyHelper.money_to_text(30000, "PYG").
|
96
|
-
MoneyHelper.money_to_text(30000, "RUB").
|
97
|
-
MoneyHelper.money_to_text(30000, "THB").
|
98
|
-
MoneyHelper.money_to_text(30000, "TOP").
|
99
|
-
MoneyHelper.money_to_text(30000, "TMT").
|
100
|
-
MoneyHelper.money_to_text(30000, "UAH").
|
101
|
-
MoneyHelper.money_to_text(30000, "VND").
|
102
|
-
MoneyHelper.money_to_text(30000, "WST").
|
103
|
-
MoneyHelper.money_to_text(30000, "ZAR").
|
76
|
+
expect(MoneyHelper.money_to_text(30000, "AMD")).to eql("AMD դր.30,000")
|
77
|
+
expect(MoneyHelper.money_to_text(30000, "BDT")).to eql("BDT ৳30,000")
|
78
|
+
expect(MoneyHelper.money_to_text(30000, "BRL")).to eql("BRL R$30.000")
|
79
|
+
expect(MoneyHelper.money_to_text(30000, "GMD")).to eql("GMD D30,000")
|
80
|
+
expect(MoneyHelper.money_to_text(30000, "GEL")).to eql("GEL ლ30,000")
|
81
|
+
expect(MoneyHelper.money_to_text(30000, "GHS")).to eql("GHS ₵30,000")
|
82
|
+
expect(MoneyHelper.money_to_text(30000, "GTQ")).to eql("GTQ Q30,000")
|
83
|
+
expect(MoneyHelper.money_to_text(30000, "HTG")).to eql("HTG G30,000")
|
84
|
+
expect(MoneyHelper.money_to_text(30000, "IDR")).to eql("IDR Rp30.000")
|
85
|
+
expect(MoneyHelper.money_to_text(30000, "ILS")).to eql("ILS ₪30,000")
|
86
|
+
expect(MoneyHelper.money_to_text(30000, "INR")).to eql("INR ₹30,000")
|
87
|
+
expect(MoneyHelper.money_to_text(30000, "KHR")).to eql("KHR ៛30,000")
|
88
|
+
expect(MoneyHelper.money_to_text(30000, "KPW")).to eql("KPW ₩30,000")
|
89
|
+
expect(MoneyHelper.money_to_text(30000, "LAK")).to eql("LAK ₭30,000")
|
90
|
+
expect(MoneyHelper.money_to_text(30000, "MNT")).to eql("MNT ₮30,000")
|
91
|
+
expect(MoneyHelper.money_to_text(30000, "NIO")).to eql("NIO C$30,000")
|
92
|
+
expect(MoneyHelper.money_to_text(30000, "NGN")).to eql("NGN ₦30,000")
|
93
|
+
expect(MoneyHelper.money_to_text(30000, "PGK")).to eql("PGK K30,000")
|
94
|
+
expect(MoneyHelper.money_to_text(30000, "PHP")).to eql("PHP ₱30,000")
|
95
|
+
expect(MoneyHelper.money_to_text(30000, "PYG")).to eql("PYG ₲30,000")
|
96
|
+
expect(MoneyHelper.money_to_text(30000, "RUB")).to eql("RUB ₽30.000")
|
97
|
+
expect(MoneyHelper.money_to_text(30000, "THB")).to eql("THB ฿30,000")
|
98
|
+
expect(MoneyHelper.money_to_text(30000, "TOP")).to eql("TOP T$30,000")
|
99
|
+
expect(MoneyHelper.money_to_text(30000, "TMT")).to eql("TMT T30,000")
|
100
|
+
expect(MoneyHelper.money_to_text(30000, "UAH")).to eql("UAH ₴30,000")
|
101
|
+
expect(MoneyHelper.money_to_text(30000, "VND")).to eql("VND ₫30.000")
|
102
|
+
expect(MoneyHelper.money_to_text(30000, "WST")).to eql("WST T30,000")
|
103
|
+
expect(MoneyHelper.money_to_text(30000, "ZAR")).to eql("ZAR R30,000")
|
104
104
|
end
|
105
105
|
it "includes only ISO code for currencies that don't have a symbol" do
|
106
|
-
MoneyHelper.money_to_text(30000, "UZS").
|
106
|
+
expect(MoneyHelper.money_to_text(30000, "UZS")).to eql("UZS 30,000")
|
107
107
|
end
|
108
108
|
it "includes only ISO code for RTL symbols" do
|
109
|
-
MoneyHelper.money_to_text(30000, "AFN").
|
110
|
-
MoneyHelper.money_to_text(30000, "DZD").
|
111
|
-
MoneyHelper.money_to_text(30000, "BHD").
|
112
|
-
MoneyHelper.money_to_text(30000, "EGP").
|
113
|
-
MoneyHelper.money_to_text(30000, "IRR").
|
114
|
-
MoneyHelper.money_to_text(30000, "IQD").
|
115
|
-
MoneyHelper.money_to_text(30000, "JOD").
|
116
|
-
MoneyHelper.money_to_text(30000, "KWD").
|
117
|
-
MoneyHelper.money_to_text(30000, "LBP").
|
118
|
-
MoneyHelper.money_to_text(30000, "LYD").
|
119
|
-
MoneyHelper.money_to_text(30000, "MAD").
|
120
|
-
MoneyHelper.money_to_text(30000, "OMR").
|
121
|
-
MoneyHelper.money_to_text(30000, "JOD").
|
122
|
-
MoneyHelper.money_to_text(30000, "QAR").
|
123
|
-
MoneyHelper.money_to_text(30000, "SAR").
|
124
|
-
MoneyHelper.money_to_text(30000, "SYP").
|
125
|
-
MoneyHelper.money_to_text(30000, "TND").
|
126
|
-
MoneyHelper.money_to_text(30000, "AED").
|
127
|
-
MoneyHelper.money_to_text(30000, "YER").
|
109
|
+
expect(MoneyHelper.money_to_text(30000, "AFN")).to eql("AFN 30,000")
|
110
|
+
expect(MoneyHelper.money_to_text(30000, "DZD")).to eql("DZD 30,000")
|
111
|
+
expect(MoneyHelper.money_to_text(30000, "BHD")).to eql("BHD 30,000")
|
112
|
+
expect(MoneyHelper.money_to_text(30000, "EGP")).to eql("EGP 30,000")
|
113
|
+
expect(MoneyHelper.money_to_text(30000, "IRR")).to eql("IRR 30,000")
|
114
|
+
expect(MoneyHelper.money_to_text(30000, "IQD")).to eql("IQD 30,000")
|
115
|
+
expect(MoneyHelper.money_to_text(30000, "JOD")).to eql("JOD 30,000")
|
116
|
+
expect(MoneyHelper.money_to_text(30000, "KWD")).to eql("KWD 30,000")
|
117
|
+
expect(MoneyHelper.money_to_text(30000, "LBP")).to eql("LBP 30,000")
|
118
|
+
expect(MoneyHelper.money_to_text(30000, "LYD")).to eql("LYD 30,000")
|
119
|
+
expect(MoneyHelper.money_to_text(30000, "MAD")).to eql("MAD 30,000")
|
120
|
+
expect(MoneyHelper.money_to_text(30000, "OMR")).to eql("OMR 30,000")
|
121
|
+
expect(MoneyHelper.money_to_text(30000, "JOD")).to eql("JOD 30,000")
|
122
|
+
expect(MoneyHelper.money_to_text(30000, "QAR")).to eql("QAR 30,000")
|
123
|
+
expect(MoneyHelper.money_to_text(30000, "SAR")).to eql("SAR 30,000")
|
124
|
+
expect(MoneyHelper.money_to_text(30000, "SYP")).to eql("SYP 30,000")
|
125
|
+
expect(MoneyHelper.money_to_text(30000, "TND")).to eql("TND 30,000")
|
126
|
+
expect(MoneyHelper.money_to_text(30000, "AED")).to eql("AED 30,000")
|
127
|
+
expect(MoneyHelper.money_to_text(30000, "YER")).to eql("YER 30,000")
|
128
128
|
end
|
129
129
|
it "defaults to USD when an empty string or nil is passed as the currency" do
|
130
|
-
MoneyHelper.money_to_text(30000, "").
|
131
|
-
MoneyHelper.money_to_text(30000, nil).
|
130
|
+
expect(MoneyHelper.money_to_text(30000, "")).to eql("$30,000")
|
131
|
+
expect(MoneyHelper.money_to_text(30000, nil)).to eql("$30,000")
|
132
132
|
end
|
133
133
|
it "returns only the formatted numeral when number_only = true" do
|
134
|
-
MoneyHelper.money_to_text(30000, "EUR", true).
|
135
|
-
MoneyHelper.money_to_text(30000, "AUD", true).
|
136
|
-
MoneyHelper.money_to_text(30000, "AMD", true).
|
137
|
-
MoneyHelper.money_to_text(30000, "AFN", true).
|
134
|
+
expect(MoneyHelper.money_to_text(30000, "EUR", true)).to eql("30.000")
|
135
|
+
expect(MoneyHelper.money_to_text(30000, "AUD", true)).to eql("30,000")
|
136
|
+
expect(MoneyHelper.money_to_text(30000, "AMD", true)).to eql("30,000")
|
137
|
+
expect(MoneyHelper.money_to_text(30000, "AFN", true)).to eql("30,000")
|
138
138
|
end
|
139
139
|
it "returns nil if amount passed in is whitespace, empty string, or nil" do
|
140
|
-
MoneyHelper.money_to_text(" ", "USD").
|
141
|
-
MoneyHelper.money_to_text("", "USD").
|
142
|
-
MoneyHelper.money_to_text(nil, "USD").
|
140
|
+
expect(MoneyHelper.money_to_text(" ", "USD")).to be_nil
|
141
|
+
expect(MoneyHelper.money_to_text("", "USD")).to be_nil
|
142
|
+
expect(MoneyHelper.money_to_text(nil, "USD")).to be_nil
|
143
143
|
end
|
144
144
|
it "falls back to ISO code when currency can't be found" do
|
145
|
-
MoneyHelper.money_to_text(10_000, "ITL").
|
146
|
-
MoneyHelper.money_to_text(10_000, "ITL", true).
|
145
|
+
expect(MoneyHelper.money_to_text(10_000, "ITL")).to eql("ITL 10,000")
|
146
|
+
expect(MoneyHelper.money_to_text(10_000, "ITL", true)).to eql("10,000")
|
147
147
|
end
|
148
148
|
end
|
149
149
|
describe "money_range_to_text" do
|
150
150
|
it "includes no indicator for currency for the upper amount in range" do
|
151
|
-
MoneyHelper.money_range_to_text(30000, 40000, "USD").
|
152
|
-
MoneyHelper.money_range_to_text(30000, 40000, "AUD").
|
153
|
-
MoneyHelper.money_range_to_text(30000, 40000, "AMD").
|
154
|
-
MoneyHelper.money_range_to_text(30000, 40000, "AFN").
|
151
|
+
expect(MoneyHelper.money_range_to_text(30000, 40000, "USD")).to eql("$30,000 - 40,000")
|
152
|
+
expect(MoneyHelper.money_range_to_text(30000, 40000, "AUD")).to eql("AUD $30,000 - 40,000")
|
153
|
+
expect(MoneyHelper.money_range_to_text(30000, 40000, "AMD")).to eql("AMD դր.30,000 - 40,000")
|
154
|
+
expect(MoneyHelper.money_range_to_text(30000, 40000, "AFN")).to eql("AFN 30,000 - 40,000")
|
155
155
|
end
|
156
156
|
it "uses the special range amount delimeter when supplied" do
|
157
|
-
MoneyHelper.money_range_to_text(30000, 40000, "USD", "-").
|
158
|
-
MoneyHelper.money_range_to_text(30000, 40000, "AUD", "-").
|
159
|
-
MoneyHelper.money_range_to_text(30000, 40000, "AMD", "-").
|
160
|
-
MoneyHelper.money_range_to_text(30000, 40000, "AFN", "-").
|
157
|
+
expect(MoneyHelper.money_range_to_text(30000, 40000, "USD", "-")).to eql("$30,000-40,000")
|
158
|
+
expect(MoneyHelper.money_range_to_text(30000, 40000, "AUD", "-")).to eql("AUD $30,000-40,000")
|
159
|
+
expect(MoneyHelper.money_range_to_text(30000, 40000, "AMD", "-")).to eql("AMD դր.30,000-40,000")
|
160
|
+
expect(MoneyHelper.money_range_to_text(30000, 40000, "AFN", "-")).to eql("AFN 30,000-40,000")
|
161
161
|
end
|
162
162
|
it "prefixes the text 'Under ' when low amount not given" do
|
163
|
-
MoneyHelper.money_range_to_text(nil, 40000, "USD").
|
163
|
+
expect(MoneyHelper.money_range_to_text(nil, 40000, "USD")).to eql("Under $40,000")
|
164
164
|
end
|
165
165
|
it "appends the text ' and up' when high amount not given" do
|
166
|
-
MoneyHelper.money_range_to_text(30000, nil, "USD").
|
166
|
+
expect(MoneyHelper.money_range_to_text(30000, nil, "USD")).to eql("$30,000 and up")
|
167
167
|
end
|
168
168
|
it "treats as a single price when low amount and high amount are identical" do
|
169
|
-
MoneyHelper.money_range_to_text(30000, 30000, "USD").
|
169
|
+
expect(MoneyHelper.money_range_to_text(30000, 30000, "USD")).to eql("$30,000")
|
170
170
|
end
|
171
171
|
it "returns nil when both amounts are nil" do
|
172
|
-
MoneyHelper.money_range_to_text(nil, nil, "USD").
|
172
|
+
expect(MoneyHelper.money_range_to_text(nil, nil, "USD")).to be_nil
|
173
173
|
end
|
174
174
|
it "falls back to ISO code when currency can't be found" do
|
175
|
-
MoneyHelper.money_range_to_text(10_000, 20_000, "ITL").
|
175
|
+
expect(MoneyHelper.money_range_to_text(10_000, 20_000, "ITL")).to eql("ITL 10,000 - 20,000")
|
176
176
|
end
|
177
177
|
end
|
178
178
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: money_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sahil Yakhmi
|
@@ -9,50 +9,50 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-03-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: money
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ~>
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '6.
|
20
|
+
version: '6.5'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ~>
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '6.
|
27
|
+
version: '6.5'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: activesupport
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ~>
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '4'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ~>
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '4'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rspec
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ~>
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
48
|
+
version: '3'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ~>
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
55
|
+
version: '3'
|
56
56
|
description: A simple module to assist in formatting unambiguous prices and price
|
57
57
|
ranges in international currencies in a Roman Script context.
|
58
58
|
email: sahil@artsymail.net
|
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
82
|
version: '0'
|
83
83
|
requirements: []
|
84
84
|
rubyforge_project:
|
85
|
-
rubygems_version: 2.
|
85
|
+
rubygems_version: 2.4.6
|
86
86
|
signing_key:
|
87
87
|
specification_version: 4
|
88
88
|
summary: MoneyHelper international price formatting utility
|