shopify-money 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe "NullCurrency" do
4
+ let (:null_currency) {Money::NULL_CURRENCY}
5
+
6
+ it 'exposes the same public interface as Currency' do
7
+ expect(Money::NullCurrency).to quack_like Money::Currency
8
+ end
9
+
10
+ describe "#initialize" do
11
+ it "has a valid XXX iso4217 currency code" do
12
+ expect(null_currency.iso_code).to eq('XXX')
13
+ end
14
+
15
+ it "quacks like USD" do
16
+ expect(null_currency.symbol).to eq('$')
17
+ expect(null_currency.subunit_to_unit).to eq(100)
18
+ expect(null_currency.smallest_denomination).to eq(1)
19
+ end
20
+
21
+ it "has the name No Currency" do
22
+ expect(null_currency.name).to eq('No Currency')
23
+ end
24
+ end
25
+
26
+ describe "#to_s" do
27
+ it 'is shown as an empty string' do
28
+ expect(null_currency.to_s).to eq('')
29
+ end
30
+ end
31
+
32
+ describe "#compatible" do
33
+ it "returns true for currency" do
34
+ expect(null_currency.compatible?(Money::Currency.new('USD'))).to eq(true)
35
+ expect(null_currency.compatible?(Money::Currency.new('JPY'))).to eq(true)
36
+ end
37
+
38
+ it "returns true for null_currency" do
39
+ expect(null_currency.compatible?(Money::NULL_CURRENCY)).to eq(true)
40
+ end
41
+
42
+ it "returns false for nil" do
43
+ expect(null_currency.compatible?(nil)).to eq(false)
44
+ end
45
+ end
46
+ end
data/spec/schema.rb ADDED
@@ -0,0 +1,9 @@
1
+ ActiveRecord::Schema.define do
2
+ create_table "money_records", :force => true do |t|
3
+ t.decimal "price", precision: 20, scale: 3, default: '0.000'
4
+ t.string "currency", limit: 3
5
+ t.decimal "prix", precision: 20, scale: 3, default: '0.000'
6
+ t.string "devise", limit: 3
7
+ t.decimal "price_usd"
8
+ end
9
+ end
@@ -0,0 +1,74 @@
1
+ require 'simplecov'
2
+ SimpleCov.minimum_coverage 100
3
+ SimpleCov.start do
4
+ add_filter "/spec/"
5
+ end
6
+
7
+ if ENV['CI'] == 'true'
8
+ require 'codecov'
9
+ SimpleCov.formatter = SimpleCov::Formatter::Codecov
10
+ end
11
+
12
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
13
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
14
+
15
+ require 'rspec'
16
+ require 'pry-byebug'
17
+ require 'database_cleaner'
18
+
19
+ require 'rails'
20
+ require 'active_record'
21
+ require 'money'
22
+
23
+ Money.active_support_deprecator.behavior = :raise
24
+ Money.default_currency = Money::Currency.new('CAD')
25
+
26
+ ActiveRecord::Base.establish_connection :adapter => "sqlite3", :database => ":memory:"
27
+
28
+ load File.join(File.dirname(__FILE__), "schema.rb")
29
+
30
+ # Requires supporting files with custom matchers and macros, etc,
31
+ # in ./support/ and its subdirectories.
32
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
33
+
34
+ RSpec.configure do |config|
35
+ config.order = :random
36
+
37
+ # Enable flags like --only-failures and --next-failure
38
+ config.example_status_persistence_file_path = ".rspec_status"
39
+
40
+ config.disable_monkey_patching!
41
+
42
+ config.expect_with :rspec do |c|
43
+ c.syntax = :expect
44
+ end
45
+
46
+ config.mock_with :rspec do |mocks|
47
+ mocks.verify_partial_doubles = true
48
+ end
49
+
50
+ config.before(:suite) do
51
+ DatabaseCleaner.strategy = :transaction
52
+ DatabaseCleaner.clean_with(:truncation)
53
+ end
54
+
55
+ config.around(:each) do |example|
56
+ DatabaseCleaner.cleaning do
57
+ example.run
58
+ end
59
+ end
60
+ end
61
+
62
+ RSpec::Matchers.define :quack_like do
63
+ match do
64
+ missing_methods.empty?
65
+ end
66
+
67
+ failure_message do
68
+ "expected #{actual.name} to respond to #{missing_methods.join(', ')}"
69
+ end
70
+
71
+ def missing_methods
72
+ expected.instance_methods - actual.instance_methods
73
+ end
74
+ end
metadata ADDED
@@ -0,0 +1,196 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shopify-money
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.10.0
5
+ platform: ruby
6
+ authors:
7
+ - Shopify Inc
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-04-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: simplecov
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.2'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: database_cleaner
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.6'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.6'
83
+ - !ruby/object:Gem::Dependency
84
+ name: sqlite3
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.3'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.3'
97
+ - !ruby/object:Gem::Dependency
98
+ name: bigdecimal
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 1.3.2
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 1.3.2
111
+ description: Manage money in Shopify with a class that wont lose pennies during division!
112
+ email: gems@shopify.com
113
+ executables:
114
+ - console
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".document"
119
+ - ".gitignore"
120
+ - ".rspec"
121
+ - Gemfile
122
+ - LICENSE.txt
123
+ - README.md
124
+ - Rakefile
125
+ - bin/console
126
+ - circle.yml
127
+ - config/currency_historic.json
128
+ - config/currency_iso.json
129
+ - config/currency_non_iso.json
130
+ - dev.yml
131
+ - lib/money.rb
132
+ - lib/money/accounting_money_parser.rb
133
+ - lib/money/core_extensions.rb
134
+ - lib/money/currency.rb
135
+ - lib/money/currency/loader.rb
136
+ - lib/money/deprecations.rb
137
+ - lib/money/helpers.rb
138
+ - lib/money/money.rb
139
+ - lib/money/money_parser.rb
140
+ - lib/money/null_currency.rb
141
+ - lib/money/version.rb
142
+ - lib/money_accessor.rb
143
+ - lib/money_column.rb
144
+ - lib/money_column/active_record_hooks.rb
145
+ - lib/money_column/active_record_type.rb
146
+ - lib/money_column/railtie.rb
147
+ - money.gemspec
148
+ - spec/accounting_money_parser_spec.rb
149
+ - spec/core_extensions_spec.rb
150
+ - spec/currency/loader_spec.rb
151
+ - spec/currency_spec.rb
152
+ - spec/helpers_spec.rb
153
+ - spec/money_accessor_spec.rb
154
+ - spec/money_column_spec.rb
155
+ - spec/money_parser_spec.rb
156
+ - spec/money_spec.rb
157
+ - spec/null_currency_spec.rb
158
+ - spec/schema.rb
159
+ - spec/spec_helper.rb
160
+ homepage: https://github.com/Shopify/money
161
+ licenses:
162
+ - MIT
163
+ metadata: {}
164
+ post_install_message:
165
+ rdoc_options: []
166
+ require_paths:
167
+ - lib
168
+ required_ruby_version: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ required_rubygems_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ requirements: []
179
+ rubyforge_project:
180
+ rubygems_version: 2.6.14
181
+ signing_key:
182
+ specification_version: 4
183
+ summary: Shopify's money gem
184
+ test_files:
185
+ - spec/accounting_money_parser_spec.rb
186
+ - spec/core_extensions_spec.rb
187
+ - spec/currency/loader_spec.rb
188
+ - spec/currency_spec.rb
189
+ - spec/helpers_spec.rb
190
+ - spec/money_accessor_spec.rb
191
+ - spec/money_column_spec.rb
192
+ - spec/money_parser_spec.rb
193
+ - spec/money_spec.rb
194
+ - spec/null_currency_spec.rb
195
+ - spec/schema.rb
196
+ - spec/spec_helper.rb