shopify-money 3.1.0 → 3.1.2
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 +4 -4
- data/.github/workflows/tests.yml +1 -1
- data/.ruby-version +1 -1
- data/Gemfile.lock +2 -2
- data/lib/money/config.rb +4 -0
- data/lib/money/helpers.rb +1 -0
- data/lib/money/version.rb +1 -1
- data/spec/config_spec.rb +18 -0
- data/spec/money_spec.rb +6 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/splitter_spec.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03fea29a7733cd7ac14493fff381a197b42a16de9369c8a15b0bba9905f7a8a0
|
4
|
+
data.tar.gz: '025213910adf2f5090dfb7afaa85f715f05515094e15f14c25b5805eaef569eb'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dad64b959edcde085fc92904dd442babdc33122c7b2c30b91e204e597fd38e547ccf62c3e6881d78d1a2b2005581d27dcad1177b1d64ae066d2bfbafabe89cb5
|
7
|
+
data.tar.gz: 2047c647afe7e4a9b373997184bde9c1a84e47e410571531266fc60075a99da1a65ec4de685c6e79fd852e7de61af427a40440e317ad8a13014a8cc4ccd4f372
|
data/.github/workflows/tests.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.4.2
|
data/Gemfile.lock
CHANGED
data/lib/money/config.rb
CHANGED
data/lib/money/helpers.rb
CHANGED
data/lib/money/version.rb
CHANGED
data/spec/config_spec.rb
CHANGED
@@ -72,7 +72,25 @@ RSpec.describe "Money::Config" do
|
|
72
72
|
it 'can be set to true' do
|
73
73
|
config = Money::Config.new
|
74
74
|
config.experimental_crypto_currencies = true
|
75
|
+
expect(config.experimental_crypto_currencies).to be(true)
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'can be set to true using the bang method' do
|
79
|
+
config = Money::Config.new
|
80
|
+
config.experimental_crypto_currencies!
|
75
81
|
expect(config.experimental_crypto_currencies).to eq(true)
|
76
82
|
end
|
77
83
|
end
|
84
|
+
|
85
|
+
describe 'legacy_json_format' do
|
86
|
+
it 'defaults to false' do
|
87
|
+
expect(Money::Config.new.legacy_json_format).to eq(false)
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'can be set to true using the bang method' do
|
91
|
+
config = Money::Config.new
|
92
|
+
config.legacy_json_format!
|
93
|
+
expect(config.legacy_json_format).to eq(true)
|
94
|
+
end
|
95
|
+
end
|
78
96
|
end
|
data/spec/money_spec.rb
CHANGED
@@ -457,6 +457,12 @@ RSpec.describe "Money" do
|
|
457
457
|
expect(Money.from_subunits(100, 'UGX', format: :stripe)).to eq(Money.new(1, 'UGX'))
|
458
458
|
end
|
459
459
|
|
460
|
+
it 'overrides the subunit_to_unit amount for USDC' do
|
461
|
+
configure(experimental_crypto_currencies: true) do
|
462
|
+
expect(Money.from_subunits(500000, "USDC", format: :stripe)).to eq(Money.new(0.50, 'USDC'))
|
463
|
+
end
|
464
|
+
end
|
465
|
+
|
460
466
|
it 'fallbacks to the default subunit_to_unit amount if no override is specified' do
|
461
467
|
expect(Money.from_subunits(100, 'USD', format: :stripe)).to eq(Money.new(1, 'USD'))
|
462
468
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -81,7 +81,7 @@ def configure(default_currency: nil, legacy_json_format: nil, legacy_deprecation
|
|
81
81
|
config.legacy_json_format! if legacy_json_format
|
82
82
|
config.legacy_deprecations! if legacy_deprecations
|
83
83
|
config.legacy_default_currency! if legacy_default_currency
|
84
|
-
config.experimental_crypto_currencies
|
84
|
+
config.experimental_crypto_currencies! if experimental_crypto_currencies
|
85
85
|
end
|
86
86
|
yield
|
87
87
|
ensure
|
data/spec/splitter_spec.rb
CHANGED
@@ -48,6 +48,12 @@ RSpec.describe "Money::Splitter" do
|
|
48
48
|
expect(moneys[2].value).to eq(33)
|
49
49
|
end
|
50
50
|
|
51
|
+
specify "#spit results behaves like an array" do
|
52
|
+
moneys = Money.new(100, 'JPY').split(3)
|
53
|
+
expect(moneys.size).to eq(3)
|
54
|
+
expect(moneys[3]).to eq(nil)
|
55
|
+
end
|
56
|
+
|
51
57
|
specify "#split return respond to #first" do
|
52
58
|
expect(Money.new(100).split(3).first).to eq(Money.new(33.34))
|
53
59
|
expect(Money.new(100).split(3).first(2)).to eq([Money.new(33.34), Money.new(33.33)])
|