shopify-money 2.2.2 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +8 -0
- data/.github/workflows/tests.yml +3 -3
- data/.gitignore +2 -1
- data/.rubocop.yml +36 -0
- data/.ruby-version +1 -1
- data/Gemfile +4 -1
- data/Gemfile.lock +167 -121
- data/README.md +10 -4
- data/Rakefile +2 -2
- data/config/currency_historic.yml +44 -2
- data/config/currency_iso.yml +38 -64
- data/lib/money/allocator.rb +13 -9
- data/lib/money/config.rb +8 -0
- data/lib/money/core_extensions.rb +11 -8
- data/lib/money/currency/loader.rb +4 -3
- data/lib/money/currency.rb +12 -3
- data/lib/money/deprecations.rb +22 -4
- data/lib/money/errors.rb +1 -0
- data/lib/money/helpers.rb +3 -6
- data/lib/money/money.rb +58 -35
- data/lib/money/null_currency.rb +11 -3
- data/lib/money/parser/accounting.rb +1 -0
- data/lib/money/parser/fuzzy.rb +16 -23
- data/lib/money/parser/locale_aware.rb +3 -6
- data/lib/money/parser/simple.rb +2 -1
- data/lib/money/rails/job_argument_serializer.rb +0 -1
- data/lib/money/railtie.rb +5 -3
- data/lib/money/splitter.rb +20 -24
- data/lib/money/version.rb +2 -1
- data/lib/money.rb +1 -0
- data/lib/money_column/active_record_hooks.rb +9 -6
- data/lib/money_column/active_record_type.rb +7 -4
- data/lib/money_column/railtie.rb +2 -1
- data/lib/money_column.rb +1 -0
- data/lib/rubocop/cop/money/missing_currency.rb +16 -23
- data/lib/rubocop/cop/money/zero_money.rb +7 -13
- data/lib/shopify-money.rb +1 -0
- data/money.gemspec +6 -6
- data/spec/config_spec.rb +14 -0
- data/spec/core_extensions_spec.rb +6 -2
- data/spec/deprecations_spec.rb +1 -2
- data/spec/helpers_spec.rb +2 -5
- data/spec/money_spec.rb +49 -14
- data/spec/parser/accounting_spec.rb +2 -5
- data/spec/parser/fuzzy_spec.rb +7 -16
- data/spec/rubocop/cop/money/missing_currency_spec.rb +7 -7
- data/spec/rubocop/cop/money/zero_money_spec.rb +2 -2
- metadata +19 -42
@@ -3,7 +3,9 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module Money
|
6
|
-
class ZeroMoney <
|
6
|
+
class ZeroMoney < Base
|
7
|
+
extend RuboCop::Cop::AutoCorrector
|
8
|
+
|
7
9
|
# `Money.zero` and it's alias `empty`, with or without currency
|
8
10
|
# argument is removed in favour of the more explicit Money.new
|
9
11
|
# syntax. Supplying it with a real currency is preferred for
|
@@ -31,21 +33,13 @@ module RuboCop
|
|
31
33
|
PATTERN
|
32
34
|
|
33
35
|
def on_send(node)
|
34
|
-
money_zero(node) do |currency_arg|
|
35
|
-
add_offense(node, message: format(MSG, currency: replacement_currency(currency_arg)))
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def autocorrect(node)
|
40
36
|
receiver, _ = *node
|
41
37
|
|
42
|
-
|
43
|
-
|
44
|
-
replacement_currency = replacement_currency(currency_arg)
|
45
|
-
|
38
|
+
money_zero(node) do |currency_arg|
|
39
|
+
add_offense(node, message: format(MSG, currency: replacement_currency(currency_arg))) do |corrector|
|
46
40
|
corrector.replace(
|
47
41
|
node.loc.expression,
|
48
|
-
"#{receiver.source}.new(0, #{replacement_currency})"
|
42
|
+
"#{receiver.source}.new(0, #{replacement_currency(currency_arg)})",
|
49
43
|
)
|
50
44
|
end
|
51
45
|
end
|
@@ -55,7 +49,7 @@ module RuboCop
|
|
55
49
|
|
56
50
|
def replacement_currency(currency_arg)
|
57
51
|
return currency_arg.first.source unless currency_arg.empty?
|
58
|
-
return "'#{cop_config[
|
52
|
+
return "'#{cop_config["ReplacementCurrency"]}'" if cop_config['ReplacementCurrency']
|
59
53
|
|
60
54
|
'Money::NULL_CURRENCY'
|
61
55
|
end
|
data/lib/shopify-money.rb
CHANGED
data/money.gemspec
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
# frozen_string_literal: true
|
3
|
+
|
3
4
|
require_relative "lib/money/version"
|
4
5
|
|
5
6
|
Gem::Specification.new do |s|
|
@@ -16,16 +17,15 @@ Gem::Specification.new do |s|
|
|
16
17
|
s.metadata['allowed_push_host'] = "https://rubygems.org"
|
17
18
|
|
18
19
|
s.add_development_dependency("bundler")
|
19
|
-
s.add_development_dependency("
|
20
|
-
s.add_development_dependency("rails", "~>
|
20
|
+
s.add_development_dependency("database_cleaner", "~> 2.0")
|
21
|
+
s.add_development_dependency("rails", "~> 7.2")
|
21
22
|
s.add_development_dependency("rspec", "~> 3.2")
|
22
|
-
s.add_development_dependency("
|
23
|
+
s.add_development_dependency("simplecov", ">= 0")
|
23
24
|
s.add_development_dependency("sqlite3")
|
24
25
|
|
25
|
-
s.required_ruby_version = '>= 3.
|
26
|
+
s.required_ruby_version = '>= 3.1'
|
26
27
|
|
27
|
-
s.files =
|
28
|
+
s.files = %x(git ls-files).split($/)
|
28
29
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
29
|
-
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
30
30
|
s.require_paths = ["lib"]
|
31
31
|
end
|
data/spec/config_spec.rb
CHANGED
@@ -2,6 +2,20 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
RSpec.describe "Money::Config" do
|
5
|
+
describe 'thread safety' do
|
6
|
+
it 'does not share the same config across threads' do
|
7
|
+
configure(legacy_deprecations: true, default_currency: 'USD') do
|
8
|
+
expect(Money.config.legacy_deprecations).to eq(true)
|
9
|
+
expect(Money.default_currency).to eq('USD')
|
10
|
+
thread = Thread.new do
|
11
|
+
expect(Money.config.legacy_deprecations).to eq(false)
|
12
|
+
expect(Money.default_currency).to eq(nil)
|
13
|
+
end
|
14
|
+
thread.join
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
5
19
|
describe 'legacy_deprecations' do
|
6
20
|
it "respects the default currency" do
|
7
21
|
configure(default_currency: 'USD', legacy_deprecations: true) do
|
@@ -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(
|
57
|
-
|
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"))
|
data/spec/deprecations_spec.rb
CHANGED
@@ -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
|
-
|
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
|
49
|
-
|
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)
|
@@ -58,6 +62,14 @@ RSpec.describe "Money" do
|
|
58
62
|
end
|
59
63
|
end
|
60
64
|
|
65
|
+
it "#without_legacy_deprecations bypasses the legacy deprecations and gives the real behavior" do
|
66
|
+
configure(legacy_deprecations: true) do
|
67
|
+
Money.without_legacy_deprecations do
|
68
|
+
expect{ Money.new(1, 'USD').to_money('CAD') }.to raise_error(Money::IncompatibleCurrencyError)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
61
73
|
it "#to_money raises when changing currency" do
|
62
74
|
expect{ Money.new(1, 'USD').to_money('CAD') }.to raise_error(Money::IncompatibleCurrencyError)
|
63
75
|
end
|
@@ -104,13 +116,6 @@ RSpec.describe "Money" do
|
|
104
116
|
end
|
105
117
|
end
|
106
118
|
|
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
119
|
it "raises when constructed with an invalid string" do
|
115
120
|
expect{ Money.new('invalid') }.to raise_error(ArgumentError)
|
116
121
|
end
|
@@ -388,6 +393,36 @@ RSpec.describe "Money" do
|
|
388
393
|
expect(JSON.dump(Money.new(1.00, "CAD"))).to eq('{"value":"1.00","currency":"CAD"}')
|
389
394
|
end
|
390
395
|
|
396
|
+
describe ".from_hash" do
|
397
|
+
it "is the inverse operation of #to_h" do
|
398
|
+
one_cad = Money.new(1, "CAD")
|
399
|
+
expect(Money.from_hash(one_cad.to_h)).to eq(one_cad)
|
400
|
+
end
|
401
|
+
|
402
|
+
it "creates Money object from hash with expected keys" do
|
403
|
+
expect(Money.from_hash({ value: 1.01, currency: "CAD" })).to eq(Money.new(1.01, "CAD"))
|
404
|
+
end
|
405
|
+
|
406
|
+
it "raises if Hash does not have the expected keys" do
|
407
|
+
expect { Money.from_hash({ "val": 1.0 }) }.to raise_error(KeyError)
|
408
|
+
end
|
409
|
+
end
|
410
|
+
|
411
|
+
describe ".from_json" do
|
412
|
+
it "is the inverse operation of #to_json" do
|
413
|
+
one_cad = Money.new(1, "CAD")
|
414
|
+
expect(Money.from_json(one_cad.to_json)).to eq(one_cad)
|
415
|
+
end
|
416
|
+
|
417
|
+
it "creates Money object from JSON-encoded string" do
|
418
|
+
expect(Money.from_json('{ "value": 1.01, "currency": "CAD" }')).to eq(Money.new(1.01, "CAD"))
|
419
|
+
end
|
420
|
+
|
421
|
+
it "raises if JSON string is malformed" do
|
422
|
+
expect { Money.from_json('{ "val": 1.0 }') }.to raise_error(KeyError)
|
423
|
+
end
|
424
|
+
end
|
425
|
+
|
391
426
|
it "supports absolute value" do
|
392
427
|
expect(Money.new(-1.00).abs).to eq(Money.new(1.00))
|
393
428
|
end
|
@@ -612,13 +647,13 @@ RSpec.describe "Money" do
|
|
612
647
|
configure(legacy_deprecations: true) { test.run }
|
613
648
|
end
|
614
649
|
|
615
|
-
it { expect
|
616
|
-
it { expect
|
617
|
-
it { expect
|
618
|
-
it { expect
|
619
|
-
it { expect
|
620
|
-
it { expect
|
621
|
-
it { expect
|
650
|
+
it { expect { cad_10 <=> coercible_object }.to(raise_error(TypeError)) }
|
651
|
+
it { expect { cad_10 > coercible_object }.to(raise_error(TypeError)) }
|
652
|
+
it { expect { cad_10 >= coercible_object }.to(raise_error(TypeError)) }
|
653
|
+
it { expect { cad_10 <= coercible_object }.to(raise_error(TypeError)) }
|
654
|
+
it { expect { cad_10 < coercible_object }.to(raise_error(TypeError)) }
|
655
|
+
it { expect { cad_10 + coercible_object }.to(raise_error(TypeError)) }
|
656
|
+
it { expect { cad_10 - coercible_object }.to(raise_error(TypeError)) }
|
622
657
|
end
|
623
658
|
end
|
624
659
|
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
|
-
|
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(
|
122
|
+
expect(@parser.parse("1.000")).to eq(Money.new(1.00))
|
126
123
|
end
|
127
124
|
end
|
128
125
|
|
data/spec/parser/fuzzy_spec.rb
CHANGED
@@ -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
|
-
|
16
|
-
|
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(
|
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
|
-
|
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
|
-
|
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(
|
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(
|
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
|
@@ -12,7 +12,7 @@ RSpec.describe RuboCop::Cop::Money::MissingCurrency do
|
|
12
12
|
it 'registers an offense and corrects for Money.new without a currency argument' do
|
13
13
|
expect_offense(<<~RUBY)
|
14
14
|
Money.new(1)
|
15
|
-
^^^^^^^^^^^^ Money is missing currency argument
|
15
|
+
^^^^^^^^^^^^ Money/MissingCurrency: Money is missing currency argument
|
16
16
|
RUBY
|
17
17
|
|
18
18
|
expect_correction(<<~RUBY)
|
@@ -36,7 +36,7 @@ RSpec.describe RuboCop::Cop::Money::MissingCurrency do
|
|
36
36
|
it 'registers an offense and corrects for Money.new without a currency argument' do
|
37
37
|
expect_offense(<<~RUBY)
|
38
38
|
Money.new
|
39
|
-
^^^^^^^^^ Money is missing currency argument
|
39
|
+
^^^^^^^^^ Money/MissingCurrency: Money is missing currency argument
|
40
40
|
RUBY
|
41
41
|
|
42
42
|
expect_correction(<<~RUBY)
|
@@ -47,7 +47,7 @@ RSpec.describe RuboCop::Cop::Money::MissingCurrency do
|
|
47
47
|
it 'registers an offense and corrects for Money.from_amount without a currency argument' do
|
48
48
|
expect_offense(<<~RUBY)
|
49
49
|
Money.from_amount(1)
|
50
|
-
^^^^^^^^^^^^^^^^^^^^ Money is missing currency argument
|
50
|
+
^^^^^^^^^^^^^^^^^^^^ Money/MissingCurrency: Money is missing currency argument
|
51
51
|
RUBY
|
52
52
|
|
53
53
|
expect_correction(<<~RUBY)
|
@@ -64,7 +64,7 @@ RSpec.describe RuboCop::Cop::Money::MissingCurrency do
|
|
64
64
|
it 'registers an offense and corrects for Money.from_cents without a currency argument' do
|
65
65
|
expect_offense(<<~RUBY)
|
66
66
|
Money.from_cents(1)
|
67
|
-
^^^^^^^^^^^^^^^^^^^ Money is missing currency argument
|
67
|
+
^^^^^^^^^^^^^^^^^^^ Money/MissingCurrency: Money is missing currency argument
|
68
68
|
RUBY
|
69
69
|
|
70
70
|
expect_correction(<<~RUBY)
|
@@ -81,7 +81,7 @@ RSpec.describe RuboCop::Cop::Money::MissingCurrency do
|
|
81
81
|
it 'registers an offense and corrects for to_money without a currency argument' do
|
82
82
|
expect_offense(<<~RUBY)
|
83
83
|
'1'.to_money
|
84
|
-
^^^^^^^^^^^^ to_money is missing currency argument
|
84
|
+
^^^^^^^^^^^^ Money/MissingCurrency: to_money is missing currency argument
|
85
85
|
RUBY
|
86
86
|
|
87
87
|
expect_correction(<<~RUBY)
|
@@ -92,7 +92,7 @@ RSpec.describe RuboCop::Cop::Money::MissingCurrency do
|
|
92
92
|
it 'registers an offense and corrects for safe navigation to_money without a currency argument' do
|
93
93
|
expect_offense(<<~RUBY)
|
94
94
|
item&.to_money
|
95
|
-
^^^^^^^^^^^^^^ to_money is missing currency argument
|
95
|
+
^^^^^^^^^^^^^^ Money/MissingCurrency: to_money is missing currency argument
|
96
96
|
RUBY
|
97
97
|
|
98
98
|
expect_correction(<<~RUBY)
|
@@ -109,7 +109,7 @@ RSpec.describe RuboCop::Cop::Money::MissingCurrency do
|
|
109
109
|
it 'registers an offense and corrects for to_money block pass form' do
|
110
110
|
expect_offense(<<~RUBY)
|
111
111
|
['1'].map(&:to_money)
|
112
|
-
^^^^^^^^^^^^^^^^^^^^^ to_money is missing currency argument
|
112
|
+
^^^^^^^^^^^^^^^^^^^^^ Money/MissingCurrency: to_money is missing currency argument
|
113
113
|
RUBY
|
114
114
|
|
115
115
|
expect_correction(<<~RUBY)
|
@@ -12,7 +12,7 @@ RSpec.describe RuboCop::Cop::Money::ZeroMoney do
|
|
12
12
|
it 'registers an offense and corrects Money.zero without currency' do
|
13
13
|
expect_offense(<<~RUBY)
|
14
14
|
Money.zero
|
15
|
-
^^^^^^^^^^ Money.zero is removed, use `Money.new(0, Money::NULL_CURRENCY)`.
|
15
|
+
^^^^^^^^^^ Money/ZeroMoney: Money.zero is removed, use `Money.new(0, Money::NULL_CURRENCY)`.
|
16
16
|
RUBY
|
17
17
|
|
18
18
|
expect_correction(<<~RUBY)
|
@@ -23,7 +23,7 @@ RSpec.describe RuboCop::Cop::Money::ZeroMoney do
|
|
23
23
|
it 'registers an offense and corrects Money.zero with currency' do
|
24
24
|
expect_offense(<<~RUBY)
|
25
25
|
Money.zero('CAD')
|
26
|
-
^^^^^^^^^^^^^^^^^ Money.zero is removed, use `Money.new(0, 'CAD')`.
|
26
|
+
^^^^^^^^^^^^^^^^^ Money/ZeroMoney: Money.zero is removed, use `Money.new(0, 'CAD')`.
|
27
27
|
RUBY
|
28
28
|
|
29
29
|
expect_correction(<<~RUBY)
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopify-money
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify Inc
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-02-19 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: bundler
|
@@ -25,33 +24,33 @@ dependencies:
|
|
25
24
|
- !ruby/object:Gem::Version
|
26
25
|
version: '0'
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
27
|
+
name: database_cleaner
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
30
29
|
requirements:
|
31
|
-
- - "
|
30
|
+
- - "~>"
|
32
31
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
32
|
+
version: '2.0'
|
34
33
|
type: :development
|
35
34
|
prerelease: false
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
37
36
|
requirements:
|
38
|
-
- - "
|
37
|
+
- - "~>"
|
39
38
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
39
|
+
version: '2.0'
|
41
40
|
- !ruby/object:Gem::Dependency
|
42
41
|
name: rails
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
44
43
|
requirements:
|
45
44
|
- - "~>"
|
46
45
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
46
|
+
version: '7.2'
|
48
47
|
type: :development
|
49
48
|
prerelease: false
|
50
49
|
version_requirements: !ruby/object:Gem::Requirement
|
51
50
|
requirements:
|
52
51
|
- - "~>"
|
53
52
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
53
|
+
version: '7.2'
|
55
54
|
- !ruby/object:Gem::Dependency
|
56
55
|
name: rspec
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,19 +66,19 @@ dependencies:
|
|
67
66
|
- !ruby/object:Gem::Version
|
68
67
|
version: '3.2'
|
69
68
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
69
|
+
name: simplecov
|
71
70
|
requirement: !ruby/object:Gem::Requirement
|
72
71
|
requirements:
|
73
|
-
- - "
|
72
|
+
- - ">="
|
74
73
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
74
|
+
version: '0'
|
76
75
|
type: :development
|
77
76
|
prerelease: false
|
78
77
|
version_requirements: !ruby/object:Gem::Requirement
|
79
78
|
requirements:
|
80
|
-
- - "
|
79
|
+
- - ">="
|
81
80
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
81
|
+
version: '0'
|
83
82
|
- !ruby/object:Gem::Dependency
|
84
83
|
name: sqlite3
|
85
84
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,10 +101,12 @@ extensions: []
|
|
102
101
|
extra_rdoc_files: []
|
103
102
|
files:
|
104
103
|
- ".document"
|
104
|
+
- ".github/dependabot.yml"
|
105
105
|
- ".github/workflows/cla.yml"
|
106
106
|
- ".github/workflows/tests.yml"
|
107
107
|
- ".gitignore"
|
108
108
|
- ".rspec"
|
109
|
+
- ".rubocop.yml"
|
109
110
|
- ".ruby-version"
|
110
111
|
- Gemfile
|
111
112
|
- Gemfile.lock
|
@@ -173,7 +174,6 @@ licenses:
|
|
173
174
|
- MIT
|
174
175
|
metadata:
|
175
176
|
allowed_push_host: https://rubygems.org
|
176
|
-
post_install_message:
|
177
177
|
rdoc_options: []
|
178
178
|
require_paths:
|
179
179
|
- lib
|
@@ -181,37 +181,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
181
181
|
requirements:
|
182
182
|
- - ">="
|
183
183
|
- !ruby/object:Gem::Version
|
184
|
-
version: '3.
|
184
|
+
version: '3.1'
|
185
185
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
186
|
requirements:
|
187
187
|
- - ">="
|
188
188
|
- !ruby/object:Gem::Version
|
189
189
|
version: '0'
|
190
190
|
requirements: []
|
191
|
-
rubygems_version: 3.
|
192
|
-
signing_key:
|
191
|
+
rubygems_version: 3.6.3
|
193
192
|
specification_version: 4
|
194
193
|
summary: Shopify's money gem
|
195
|
-
test_files:
|
196
|
-
- spec/allocator_spec.rb
|
197
|
-
- spec/config_spec.rb
|
198
|
-
- spec/core_extensions_spec.rb
|
199
|
-
- spec/currency/loader_spec.rb
|
200
|
-
- spec/currency_spec.rb
|
201
|
-
- spec/deprecations_spec.rb
|
202
|
-
- spec/helpers_spec.rb
|
203
|
-
- spec/money_column_spec.rb
|
204
|
-
- spec/money_spec.rb
|
205
|
-
- spec/null_currency_spec.rb
|
206
|
-
- spec/parser/accounting_spec.rb
|
207
|
-
- spec/parser/fuzzy_spec.rb
|
208
|
-
- spec/parser/locale_aware_spec.rb
|
209
|
-
- spec/parser/simple_spec.rb
|
210
|
-
- spec/rails/job_argument_serializer_spec.rb
|
211
|
-
- spec/rails_spec_helper.rb
|
212
|
-
- spec/rubocop/cop/money/missing_currency_spec.rb
|
213
|
-
- spec/rubocop/cop/money/zero_money_spec.rb
|
214
|
-
- spec/rubocop_helper.rb
|
215
|
-
- spec/schema.rb
|
216
|
-
- spec/spec_helper.rb
|
217
|
-
- spec/splitter_spec.rb
|
194
|
+
test_files: []
|