shopify-money 2.2.2 → 3.0.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: afe8dd7e74692587c2a65622a5ee6f1703ef9c0af100c0b0940f225399f2391f
4
- data.tar.gz: e925f921795d0317f06d9d01c88f981560f353a5746e6d293e103a309600f881
3
+ metadata.gz: db511ab9ce13dc4aec5a27ef380b25dd07f0be27c21967780e4b60e58b22325e
4
+ data.tar.gz: ed4d4323f3d0b405effe8ed9fd00bf87f67c96d9643076f8b7813097534c602f
5
5
  SHA512:
6
- metadata.gz: 99b9dccc03de12fd78021c9af07b26fe1897395f7762d0b14d0397064cbffc64eeb96e1e504a91591703c1e1d04c681416fbf51f60fff839939915e600a9bfe9
7
- data.tar.gz: 062a4c38ce1fff9b93df7a33d19323e995ebd3a0b74cae3882f8f3f34654febc19bfb761cdb3092838db738868b475ef7fe84002f9c04c8736d49b7484742f85
6
+ metadata.gz: 2e17c506f0d95b1dd9490b29c6b1cb9bf841042478afd1c6b333bc0c218ea6bded1a269966edf703d6927e000fa1d037234e80d5b1b96e9df5c1b71383f2959a
7
+ data.tar.gz: 374acdd9eac097da5f20d4215534146bc8f4c6406fe47df7d24707109337838754adee060dadf98b09e6522db63db35a4d351963f97efb835186d208da21c679
@@ -0,0 +1,8 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: weekly
7
+ open-pull-requests-limit: 100
8
+ registries: "*"
data/Gemfile.lock CHANGED
@@ -1,65 +1,65 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shopify-money (2.2.2)
4
+ shopify-money (3.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- actioncable (6.1.7.7)
10
- actionpack (= 6.1.7.7)
11
- activesupport (= 6.1.7.7)
9
+ actioncable (6.1.7.8)
10
+ actionpack (= 6.1.7.8)
11
+ activesupport (= 6.1.7.8)
12
12
  nio4r (~> 2.0)
13
13
  websocket-driver (>= 0.6.1)
14
- actionmailbox (6.1.7.7)
15
- actionpack (= 6.1.7.7)
16
- activejob (= 6.1.7.7)
17
- activerecord (= 6.1.7.7)
18
- activestorage (= 6.1.7.7)
19
- activesupport (= 6.1.7.7)
14
+ actionmailbox (6.1.7.8)
15
+ actionpack (= 6.1.7.8)
16
+ activejob (= 6.1.7.8)
17
+ activerecord (= 6.1.7.8)
18
+ activestorage (= 6.1.7.8)
19
+ activesupport (= 6.1.7.8)
20
20
  mail (>= 2.7.1)
21
- actionmailer (6.1.7.7)
22
- actionpack (= 6.1.7.7)
23
- actionview (= 6.1.7.7)
24
- activejob (= 6.1.7.7)
25
- activesupport (= 6.1.7.7)
21
+ actionmailer (6.1.7.8)
22
+ actionpack (= 6.1.7.8)
23
+ actionview (= 6.1.7.8)
24
+ activejob (= 6.1.7.8)
25
+ activesupport (= 6.1.7.8)
26
26
  mail (~> 2.5, >= 2.5.4)
27
27
  rails-dom-testing (~> 2.0)
28
- actionpack (6.1.7.7)
29
- actionview (= 6.1.7.7)
30
- activesupport (= 6.1.7.7)
28
+ actionpack (6.1.7.8)
29
+ actionview (= 6.1.7.8)
30
+ activesupport (= 6.1.7.8)
31
31
  rack (~> 2.0, >= 2.0.9)
32
32
  rack-test (>= 0.6.3)
33
33
  rails-dom-testing (~> 2.0)
34
34
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
35
- actiontext (6.1.7.7)
36
- actionpack (= 6.1.7.7)
37
- activerecord (= 6.1.7.7)
38
- activestorage (= 6.1.7.7)
39
- activesupport (= 6.1.7.7)
35
+ actiontext (6.1.7.8)
36
+ actionpack (= 6.1.7.8)
37
+ activerecord (= 6.1.7.8)
38
+ activestorage (= 6.1.7.8)
39
+ activesupport (= 6.1.7.8)
40
40
  nokogiri (>= 1.8.5)
41
- actionview (6.1.7.7)
42
- activesupport (= 6.1.7.7)
41
+ actionview (6.1.7.8)
42
+ activesupport (= 6.1.7.8)
43
43
  builder (~> 3.1)
44
44
  erubi (~> 1.4)
45
45
  rails-dom-testing (~> 2.0)
46
46
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
47
- activejob (6.1.7.7)
48
- activesupport (= 6.1.7.7)
47
+ activejob (6.1.7.8)
48
+ activesupport (= 6.1.7.8)
49
49
  globalid (>= 0.3.6)
50
- activemodel (6.1.7.7)
51
- activesupport (= 6.1.7.7)
52
- activerecord (6.1.7.7)
53
- activemodel (= 6.1.7.7)
54
- activesupport (= 6.1.7.7)
55
- activestorage (6.1.7.7)
56
- actionpack (= 6.1.7.7)
57
- activejob (= 6.1.7.7)
58
- activerecord (= 6.1.7.7)
59
- activesupport (= 6.1.7.7)
50
+ activemodel (6.1.7.8)
51
+ activesupport (= 6.1.7.8)
52
+ activerecord (6.1.7.8)
53
+ activemodel (= 6.1.7.8)
54
+ activesupport (= 6.1.7.8)
55
+ activestorage (6.1.7.8)
56
+ actionpack (= 6.1.7.8)
57
+ activejob (= 6.1.7.8)
58
+ activerecord (= 6.1.7.8)
59
+ activesupport (= 6.1.7.8)
60
60
  marcel (~> 1.0)
61
61
  mini_mime (>= 1.1.0)
62
- activesupport (6.1.7.7)
62
+ activesupport (6.1.7.8)
63
63
  concurrent-ruby (~> 1.0, >= 1.0.2)
64
64
  i18n (>= 1.6, < 2)
65
65
  minitest (>= 5.1)
@@ -69,16 +69,21 @@ GEM
69
69
  builder (3.2.4)
70
70
  byebug (11.1.3)
71
71
  coderay (1.1.3)
72
- concurrent-ruby (1.2.3)
72
+ concurrent-ruby (1.3.1)
73
73
  crass (1.0.6)
74
- database_cleaner (1.99.0)
74
+ database_cleaner (2.0.2)
75
+ database_cleaner-active_record (>= 2, < 3)
76
+ database_cleaner-active_record (2.2.0)
77
+ activerecord (>= 5.a)
78
+ database_cleaner-core (~> 2.0.0)
79
+ database_cleaner-core (2.0.1)
75
80
  date (3.3.4)
76
81
  diff-lcs (1.5.1)
77
82
  docile (1.4.0)
78
83
  erubi (1.12.0)
79
84
  globalid (1.2.1)
80
85
  activesupport (>= 6.1)
81
- i18n (1.14.4)
86
+ i18n (1.14.5)
82
87
  concurrent-ruby (~> 1.0)
83
88
  jaro_winkler (1.5.6)
84
89
  loofah (2.22.0)
@@ -92,7 +97,7 @@ GEM
92
97
  marcel (1.0.4)
93
98
  method_source (1.0.0)
94
99
  mini_mime (1.1.5)
95
- minitest (5.22.3)
100
+ minitest (5.23.1)
96
101
  net-imap (0.4.10)
97
102
  date
98
103
  net-protocol
@@ -103,17 +108,17 @@ GEM
103
108
  net-smtp (0.5.0)
104
109
  net-protocol
105
110
  nio4r (2.7.1)
106
- nokogiri (1.16.3-aarch64-linux)
111
+ nokogiri (1.16.5-aarch64-linux)
107
112
  racc (~> 1.4)
108
- nokogiri (1.16.3-arm-linux)
113
+ nokogiri (1.16.5-arm-linux)
109
114
  racc (~> 1.4)
110
- nokogiri (1.16.3-arm64-darwin)
115
+ nokogiri (1.16.5-arm64-darwin)
111
116
  racc (~> 1.4)
112
- nokogiri (1.16.3-x86-linux)
117
+ nokogiri (1.16.5-x86-linux)
113
118
  racc (~> 1.4)
114
- nokogiri (1.16.3-x86_64-darwin)
119
+ nokogiri (1.16.5-x86_64-darwin)
115
120
  racc (~> 1.4)
116
- nokogiri (1.16.3-x86_64-linux)
121
+ nokogiri (1.16.5-x86_64-linux)
117
122
  racc (~> 1.4)
118
123
  parallel (1.24.0)
119
124
  parser (3.3.0.5)
@@ -125,24 +130,24 @@ GEM
125
130
  pry-byebug (3.10.1)
126
131
  byebug (~> 11.0)
127
132
  pry (>= 0.13, < 0.15)
128
- racc (1.7.3)
133
+ racc (1.8.0)
129
134
  rack (2.2.9)
130
135
  rack-test (2.1.0)
131
136
  rack (>= 1.3)
132
- rails (6.1.7.7)
133
- actioncable (= 6.1.7.7)
134
- actionmailbox (= 6.1.7.7)
135
- actionmailer (= 6.1.7.7)
136
- actionpack (= 6.1.7.7)
137
- actiontext (= 6.1.7.7)
138
- actionview (= 6.1.7.7)
139
- activejob (= 6.1.7.7)
140
- activemodel (= 6.1.7.7)
141
- activerecord (= 6.1.7.7)
142
- activestorage (= 6.1.7.7)
143
- activesupport (= 6.1.7.7)
137
+ rails (6.1.7.8)
138
+ actioncable (= 6.1.7.8)
139
+ actionmailbox (= 6.1.7.8)
140
+ actionmailer (= 6.1.7.8)
141
+ actionpack (= 6.1.7.8)
142
+ actiontext (= 6.1.7.8)
143
+ actionview (= 6.1.7.8)
144
+ activejob (= 6.1.7.8)
145
+ activemodel (= 6.1.7.8)
146
+ activerecord (= 6.1.7.8)
147
+ activestorage (= 6.1.7.8)
148
+ activesupport (= 6.1.7.8)
144
149
  bundler (>= 1.15.0)
145
- railties (= 6.1.7.7)
150
+ railties (= 6.1.7.8)
146
151
  sprockets-rails (>= 2.0.0)
147
152
  rails-dom-testing (2.2.0)
148
153
  activesupport (>= 5.0.0)
@@ -151,15 +156,16 @@ GEM
151
156
  rails-html-sanitizer (1.6.0)
152
157
  loofah (~> 2.21)
153
158
  nokogiri (~> 1.14)
154
- railties (6.1.7.7)
155
- actionpack (= 6.1.7.7)
156
- activesupport (= 6.1.7.7)
159
+ railties (6.1.7.8)
160
+ actionpack (= 6.1.7.8)
161
+ activesupport (= 6.1.7.8)
157
162
  method_source
158
163
  rake (>= 12.2)
159
164
  thor (~> 1.0)
160
165
  rainbow (3.1.1)
161
166
  rake (13.2.0)
162
- rexml (3.2.6)
167
+ rexml (3.2.8)
168
+ strscan (>= 3.0.9)
163
169
  rspec (3.13.0)
164
170
  rspec-core (~> 3.13.0)
165
171
  rspec-expectations (~> 3.13.0)
@@ -201,6 +207,7 @@ GEM
201
207
  sqlite3 (1.7.3-x86-linux)
202
208
  sqlite3 (1.7.3-x86_64-darwin)
203
209
  sqlite3 (1.7.3-x86_64-linux)
210
+ strscan (3.1.0)
204
211
  thor (1.3.1)
205
212
  timeout (0.4.1)
206
213
  tzinfo (2.0.6)
@@ -209,7 +216,7 @@ GEM
209
216
  websocket-driver (0.7.6)
210
217
  websocket-extensions (>= 0.1.0)
211
218
  websocket-extensions (0.1.5)
212
- zeitwerk (2.6.13)
219
+ zeitwerk (2.6.15)
213
220
 
214
221
  PLATFORMS
215
222
  aarch64-linux
@@ -221,7 +228,7 @@ PLATFORMS
221
228
 
222
229
  DEPENDENCIES
223
230
  bundler
224
- database_cleaner (~> 1.6)
231
+ database_cleaner (~> 2.0)
225
232
  pry-byebug
226
233
  rails (~> 6.0)
227
234
  rspec (~> 3.2)
data/README.md CHANGED
@@ -18,10 +18,6 @@
18
18
 
19
19
  gem 'shopify-money'
20
20
 
21
- ## Upgrading to v1.0
22
-
23
- see instructions and breaking changes: https://github.com/Shopify/money/blob/main/UPGRADING.md
24
-
25
21
  ## Usage
26
22
 
27
23
  ``` ruby
@@ -151,6 +147,16 @@ Money::Currency.new("JPY").minor_units # => 0
151
147
  Money::Currency.new("MGA").minor_units # => 1
152
148
  ```
153
149
 
150
+ ### Convert Currency
151
+
152
+ `Money.new(money * exchange_rate, "JPY")` will raise an exception. The valid alternatives are:
153
+
154
+ ```ruby
155
+ Money.new(money.value * exchange_rate, "JPY")
156
+ # Or
157
+ money.convert_currency(exchange_rate, "JPY")
158
+ ```
159
+
154
160
  ## Money column
155
161
 
156
162
  Since money internally uses BigDecimal it's logical to use a `decimal` column
@@ -20,18 +20,20 @@ class String
20
20
  return Money.new(self, currency)
21
21
  end
22
22
 
23
+ new_value = BigDecimal(self, exception: false)&.round(currency.minor_units)
24
+ unless new_value.nil?
25
+ return Money.new(self, currency)
26
+ end
27
+
28
+ return Money.new(0, currency) if self.empty?
29
+
23
30
  Money::Parser::Fuzzy.parse(self, currency).tap do |money|
24
- new_value = BigDecimal(self, exception: false)&.round(currency.minor_units)
25
31
  old_value = money.value
26
32
 
27
33
  if new_value != old_value
28
- message = "`\"#{self}\".to_money` will soon behave like `Money.new(\"#{self}\")` and "
29
- message +=
30
- if new_value.nil?
31
- "raise an ArgumentError exception. Use the browser's locale to parse money strings."
32
- else
33
- "return #{new_value} instead of #{old_value}."
34
- end
34
+ message = "`\"#{self}\".to_money` will soon behave like `Money.new(\"#{self}\")` and " \
35
+ "raise an ArgumentError exception. Use the browser's locale to parse money strings."
36
+
35
37
  Money.deprecate(message)
36
38
  end
37
39
  end
data/lib/money/helpers.rb CHANGED
@@ -29,11 +29,7 @@ class Money
29
29
  when Rational
30
30
  BigDecimal(num, MAX_DECIMAL)
31
31
  when String
32
- decimal = BigDecimal(num, exception: !Money.config.legacy_deprecations)
33
- return decimal if decimal
34
-
35
- Money.deprecate("using Money.new('#{num}') is deprecated and will raise an ArgumentError in the next major release")
36
- DECIMAL_ZERO
32
+ BigDecimal(num)
37
33
  else
38
34
  raise ArgumentError, "could not parse as decimal #{num.inspect}"
39
35
  end
data/lib/money/money.rb CHANGED
@@ -215,6 +215,10 @@ class Money
215
215
  [ReverseOperationProxy.new(other), self]
216
216
  end
217
217
 
218
+ def convert_currency(exchange_rate, new_currency)
219
+ Money.new(value * exchange_rate, new_currency)
220
+ end
221
+
218
222
  def to_money(new_currency = nil)
219
223
  if new_currency.nil?
220
224
  return self
@@ -371,12 +375,7 @@ class Money
371
375
  yield(Money.new(other, currency))
372
376
 
373
377
  else
374
- if Money.config.legacy_deprecations && other.respond_to?(:to_money)
375
- Money.deprecate("#{other.inspect} is being implicitly coerced into a Money object. Call `to_money` on this object to transform it into a money explicitly. An TypeError will raise in the next major release")
376
- yield(other.to_money(currency))
377
- else
378
- raise TypeError, "#{other.class.name} can't be coerced into Money"
379
- end
378
+ raise TypeError, "#{other.class.name} can't be coerced into a Money object"
380
379
  end
381
380
  end
382
381
 
@@ -92,8 +92,7 @@ class Money
92
92
  number = number.to_s.strip
93
93
 
94
94
  if number.empty?
95
- if Money.config.legacy_deprecations && !strict
96
- Money.deprecate("invalid money strings will raise in the next major release \"#{input}\"")
95
+ if !strict
97
96
  return '0'
98
97
  else
99
98
  raise MoneyFormatError, "invalid money string: #{input}"
@@ -120,9 +119,7 @@ class Money
120
119
  return amount.tr(ESCAPED_NON_COMMA_MARKS, '').sub(',', '.')
121
120
  end
122
121
 
123
- if Money.config.legacy_deprecations && !strict
124
- Money.deprecate("invalid money strings will raise in the next major release \"#{input}\"")
125
- else
122
+ if strict
126
123
  raise MoneyFormatError, "invalid money string: #{input}"
127
124
  end
128
125
 
@@ -161,11 +158,6 @@ class Money
161
158
  return true
162
159
  end
163
160
 
164
- # legacy support for 1.000 USD
165
- if digits.last.size == 3 && digits.first.size <= 3 && currency.minor_units < 3
166
- return false
167
- end
168
-
169
161
  # The last mark matches the one used by the provided currency to delimiter decimals
170
162
  currency.decimal_mark == last_mark
171
163
  end
data/lib/money/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  class Money
3
- VERSION = "2.2.2"
3
+ VERSION = "3.0.0"
4
4
  end
data/money.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.add_development_dependency("simplecov", ">= 0")
20
20
  s.add_development_dependency("rails", "~> 6.0")
21
21
  s.add_development_dependency("rspec", "~> 3.2")
22
- s.add_development_dependency("database_cleaner", "~> 1.6")
22
+ s.add_development_dependency("database_cleaner", "~> 2.0")
23
23
  s.add_development_dependency("sqlite3")
24
24
 
25
25
  s.required_ruby_version = '>= 3.0'
@@ -48,13 +48,17 @@ RSpec.describe String do
48
48
  configure(legacy_deprecations: true) do
49
49
  expect(Money).to receive(:deprecate).once
50
50
  expect(" ".to_money("CAD")).to eq(Money.new(0, "CAD"))
51
+
52
+ # empty should not show a deprecation
53
+ expect("".to_money("USD")).to eq(Money.new(0, "USD"))
51
54
  end
52
55
  end
53
56
 
54
57
  it "#to_money to handle thousands delimiters" do
55
58
  configure(legacy_deprecations: true) do
56
- expect(Money).to receive(:deprecate).exactly(4).times
57
- expect("29.000".to_money("USD")).to eq(Money.new("29000", "USD"))
59
+ expect("29.000".to_money("USD")).to eq(Money.new("29.00", "USD"))
60
+
61
+ expect(Money).to receive(:deprecate).exactly(3).times
58
62
  expect("29.000,00".to_money("USD")).to eq(Money.new("29000", "USD"))
59
63
  expect("29,000".to_money("USD")).to eq(Money.new("29000", "USD"))
60
64
  expect("29,000.00".to_money("USD")).to eq(Money.new("29000", "USD"))
@@ -3,7 +3,6 @@ require 'spec_helper'
3
3
 
4
4
  RSpec.describe "deprecations" do
5
5
  it "has the deprecation_horizon as the next major release" do
6
- allow(Money).to receive(:const_get).with('VERSION').and_return("2.1.0")
7
- expect(Money.active_support_deprecator.deprecation_horizon).to eq("3.0.0")
6
+ expect(Money.active_support_deprecator.deprecation_horizon).to eq("4.0.0")
8
7
  end
9
8
  end
data/spec/helpers_spec.rb CHANGED
@@ -45,11 +45,8 @@ RSpec.describe Money::Helpers do
45
45
  expect(subject.value_to_decimal(' -1.23 ')).to eq(-amount)
46
46
  end
47
47
 
48
- it 'invalid string returns zero' do
49
- configure(legacy_deprecations: true) do
50
- expect(Money).to receive(:deprecate).once
51
- expect(subject.value_to_decimal('invalid')).to eq(0)
52
- end
48
+ it 'invalid string raises error' do
49
+ expect { subject.value_to_decimal('invalid') }.to raise_error(ArgumentError)
53
50
  end
54
51
 
55
52
  it 'raises on invalid object' do
data/spec/money_spec.rb CHANGED
@@ -28,6 +28,10 @@ RSpec.describe "Money" do
28
28
  expect(Money.new(0, Money::NULL_CURRENCY)).to eq(Money.new(0))
29
29
  end
30
30
 
31
+ it "converts to a new currency" do
32
+ expect(Money.new(10, "USD").convert_currency(150, "JPY")).to eq(Money.new(1500, "JPY"))
33
+ end
34
+
31
35
  it "returns itself with to_money" do
32
36
  expect(money.to_money).to eq(money)
33
37
  expect(amount_money.to_money).to eq(amount_money)
@@ -104,13 +108,6 @@ RSpec.describe "Money" do
104
108
  end
105
109
  end
106
110
 
107
- it "legacy_deprecations defaults to 0 when constructed with an invalid string" do
108
- configure(legacy_deprecations: true) do
109
- expect(Money).to receive(:deprecate).once
110
- expect(Money.new('invalid', 'USD')).to eq(Money.new(0.00, 'USD'))
111
- end
112
- end
113
-
114
111
  it "raises when constructed with an invalid string" do
115
112
  expect{ Money.new('invalid') }.to raise_error(ArgumentError)
116
113
  end
@@ -612,13 +609,13 @@ RSpec.describe "Money" do
612
609
  configure(legacy_deprecations: true) { test.run }
613
610
  end
614
611
 
615
- it { expect(Money).to(receive(:deprecate).once); expect(cad_10 <=> coercible_object).to(eq(0)) }
616
- it { expect(Money).to(receive(:deprecate).once); expect(cad_10 > coercible_object).to(eq(false)) }
617
- it { expect(Money).to(receive(:deprecate).once); expect(cad_10 >= coercible_object).to(eq(true)) }
618
- it { expect(Money).to(receive(:deprecate).once); expect(cad_10 <= coercible_object).to(eq(true)) }
619
- it { expect(Money).to(receive(:deprecate).once); expect(cad_10 < coercible_object).to(eq(false)) }
620
- it { expect(Money).to(receive(:deprecate).once); expect(cad_10 + coercible_object).to(eq(Money.new(20, 'CAD'))) }
621
- it { expect(Money).to(receive(:deprecate).once); expect(cad_10 - coercible_object).to(eq(Money.new(0, 'CAD'))) }
612
+ it { expect { cad_10 <=> coercible_object }.to(raise_error(TypeError)) }
613
+ it { expect { cad_10 > coercible_object }.to(raise_error(TypeError)) }
614
+ it { expect { cad_10 >= coercible_object }.to(raise_error(TypeError)) }
615
+ it { expect { cad_10 <= coercible_object }.to(raise_error(TypeError)) }
616
+ it { expect { cad_10 < coercible_object }.to(raise_error(TypeError)) }
617
+ it { expect { cad_10 + coercible_object }.to(raise_error(TypeError)) }
618
+ it { expect { cad_10 - coercible_object }.to(raise_error(TypeError)) }
622
619
  end
623
620
  end
624
621
  end
@@ -20,10 +20,7 @@ RSpec.describe Money::Parser::Accounting do
20
20
  end
21
21
 
22
22
  it "parses an invalid string to $0" do
23
- configure(legacy_deprecations: true) do
24
- expect(Money).to receive(:deprecate).once
25
- expect(@parser.parse("no money", 'USD')).to eq(Money.new(0, 'USD'))
26
- end
23
+ expect(@parser.parse("no money", 'USD')).to eq(Money.new(0, 'USD'))
27
24
  end
28
25
 
29
26
  it "parses a single digit integer string" do
@@ -122,7 +119,7 @@ RSpec.describe Money::Parser::Accounting do
122
119
 
123
120
  it "parses thousands amount" do
124
121
  Money.with_currency(Money::NULL_CURRENCY) do
125
- expect(@parser.parse("1.000")).to eq(Money.new(1000.00))
122
+ expect(@parser.parse("1.000")).to eq(Money.new(1.00))
126
123
  end
127
124
  end
128
125
 
@@ -12,11 +12,8 @@ RSpec.describe Money::Parser::Fuzzy do
12
12
  end
13
13
 
14
14
  it "parses an invalid string when not strict" do
15
- configure(legacy_deprecations: true) do
16
- expect(Money).to receive(:deprecate).twice
17
- expect(@parser.parse("no money", 'USD')).to eq(Money.new(0, 'USD'))
18
- expect(@parser.parse("1..", 'USD')).to eq(Money.new(1, 'USD'))
19
- end
15
+ expect(@parser.parse("no money", 'USD')).to eq(Money.new(0, 'USD'))
16
+ expect(@parser.parse("1..", 'USD')).to eq(Money.new(1, 'USD'))
20
17
  end
21
18
 
22
19
  it "parses raise with an invalid string and strict option" do
@@ -140,7 +137,7 @@ RSpec.describe Money::Parser::Fuzzy do
140
137
  end
141
138
 
142
139
  it "parses no currency amount" do
143
- expect(@parser.parse("1.000", Money::NULL_CURRENCY)).to eq(Money.new(1000, Money::NULL_CURRENCY))
140
+ expect(@parser.parse("1.000", Money::NULL_CURRENCY)).to eq(Money.new(1, Money::NULL_CURRENCY))
144
141
  end
145
142
 
146
143
  it "parses amount with more than 3 decimals correctly" do
@@ -152,10 +149,7 @@ RSpec.describe Money::Parser::Fuzzy do
152
149
  end
153
150
 
154
151
  it "parses amount with multiple inconsistent thousands delimiters" do
155
- configure(legacy_deprecations: true) do
156
- expect(Money).to receive(:deprecate).once
157
- expect(@parser.parse("1.1.11.111", 'USD')).to eq(Money.new(1_111_111, 'USD'))
158
- end
152
+ expect(@parser.parse("1.1.11.111", 'USD')).to eq(Money.new(1_111_111, 'USD'))
159
153
  end
160
154
 
161
155
  it "parses raises with multiple inconsistent thousands delimiters and strict option" do
@@ -226,10 +220,7 @@ RSpec.describe Money::Parser::Fuzzy do
226
220
  end
227
221
 
228
222
  it "parses amount with multiple inconsistent thousands delimiters" do
229
- configure(legacy_deprecations: true) do
230
- expect(Money).to receive(:deprecate).once
231
- expect(@parser.parse("1,1,11,111", 'USD')).to eq(Money.new(1_111_111, 'USD'))
232
- end
223
+ expect(@parser.parse("1,1,11,111", 'USD')).to eq(Money.new(1_111_111, 'USD'))
233
224
  end
234
225
 
235
226
  it "parses raises with multiple inconsistent thousands delimiters and strict option" do
@@ -255,7 +246,7 @@ RSpec.describe Money::Parser::Fuzzy do
255
246
  describe "no decimal currency" do
256
247
  it "parses thousands correctly" do
257
248
  expect(@parser.parse("1,111", "JPY")).to eq(Money.new(1_111, 'JPY'))
258
- expect(@parser.parse("1.111", "JPY")).to eq(Money.new(1_111, 'JPY'))
249
+ expect(@parser.parse("1.111", "JPY")).to eq(Money.new(1, 'JPY'))
259
250
  expect(@parser.parse("1 111", "JPY")).to eq(Money.new(1_111, 'JPY'))
260
251
  expect(@parser.parse("1111,111", "JPY")).to eq(Money.new(1_111_111, 'JPY'))
261
252
  end
@@ -270,7 +261,7 @@ RSpec.describe Money::Parser::Fuzzy do
270
261
  describe "two decimal currency" do
271
262
  it "parses thousands correctly" do
272
263
  expect(@parser.parse("1,111", "USD")).to eq(Money.new(1_111, 'USD'))
273
- expect(@parser.parse("1.111", "USD")).to eq(Money.new(1_111, 'USD'))
264
+ expect(@parser.parse("1.111", "USD")).to eq(Money.new(1.11, 'USD'))
274
265
  expect(@parser.parse("1 111", "USD")).to eq(Money.new(1_111, 'USD'))
275
266
  expect(@parser.parse("1111,111", "USD")).to eq(Money.new(1_111_111, 'USD'))
276
267
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify-money
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify Inc
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-03 00:00:00.000000000 Z
11
+ date: 2024-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.6'
75
+ version: '2.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.6'
82
+ version: '2.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: sqlite3
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -102,6 +102,7 @@ extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
104
  - ".document"
105
+ - ".github/dependabot.yml"
105
106
  - ".github/workflows/cla.yml"
106
107
  - ".github/workflows/tests.yml"
107
108
  - ".gitignore"
@@ -173,7 +174,7 @@ licenses:
173
174
  - MIT
174
175
  metadata:
175
176
  allowed_push_host: https://rubygems.org
176
- post_install_message:
177
+ post_install_message:
177
178
  rdoc_options: []
178
179
  require_paths:
179
180
  - lib
@@ -188,8 +189,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
189
  - !ruby/object:Gem::Version
189
190
  version: '0'
190
191
  requirements: []
191
- rubygems_version: 3.5.9
192
- signing_key:
192
+ rubygems_version: 3.5.17
193
+ signing_key:
193
194
  specification_version: 4
194
195
  summary: Shopify's money gem
195
196
  test_files: