money-rails 1.0.0 → 1.1.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 +4 -4
- data/README.md +34 -53
- data/lib/generators/templates/money.rb +7 -4
- data/lib/money-rails/active_model/validator.rb +1 -1
- data/lib/money-rails/active_record/monetizable.rb +23 -7
- data/lib/money-rails/configuration.rb +5 -2
- data/lib/money-rails/money.rb +4 -1
- data/lib/money-rails/mongoid/money.rb +2 -2
- data/lib/money-rails/test_helpers.rb +40 -18
- data/lib/money-rails/version.rb +1 -1
- data/money-rails.gemspec +1 -1
- data/spec/active_record/migration_extensions/schema_statements_spec.rb +8 -8
- data/spec/active_record/migration_extensions/table_spec.rb +8 -8
- data/spec/active_record/monetizable_spec.rb +195 -166
- data/spec/configuration_spec.rb +39 -22
- data/spec/dummy/app/models/dummy_product.rb +1 -0
- data/spec/dummy/app/models/product.rb +4 -0
- data/spec/dummy/config/application.rb +3 -2
- data/spec/dummy/config/locales/en-US.yml +5 -0
- data/spec/dummy/db/migrate/20141005075025_add_aliased_attr_to_products.rb +5 -0
- data/spec/dummy/db/schema.rb +2 -1
- data/spec/helpers/action_view_extension_spec.rb +45 -45
- data/spec/helpers/form_helper_spec.rb +2 -2
- data/spec/mongoid/four_spec.rb +23 -23
- data/spec/mongoid/three_spec.rb +23 -23
- data/spec/mongoid/two_spec.rb +13 -13
- data/spec/spec_helper.rb +0 -2
- data/spec/test_helpers_spec.rb +34 -22
- metadata +8 -4
data/spec/spec_helper.rb
CHANGED
@@ -4,7 +4,6 @@ require File.expand_path("../../spec/dummy/config/environment", __FILE__)
|
|
4
4
|
|
5
5
|
require 'database_cleaner'
|
6
6
|
require 'rspec/rails'
|
7
|
-
require 'rspec/autorun'
|
8
7
|
|
9
8
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
10
9
|
# in spec/support/ and its subdirectories.
|
@@ -21,5 +20,4 @@ RSpec.configure do |config|
|
|
21
20
|
# rspec-rails.
|
22
21
|
config.infer_base_class_for_anonymous_controllers = false
|
23
22
|
config.infer_spec_type_from_file_location!
|
24
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
25
23
|
end
|
data/spec/test_helpers_spec.rb
CHANGED
@@ -14,38 +14,50 @@ if defined? ActiveRecord
|
|
14
14
|
end
|
15
15
|
|
16
16
|
describe "monetize matcher" do
|
17
|
-
it "matches model attribute without a '_cents' suffix by default" do
|
18
|
-
product.should monetize(:price_cents)
|
19
|
-
end
|
20
17
|
|
21
|
-
|
22
|
-
product.should monetize(:discount).as(:discount_value)
|
23
|
-
end
|
18
|
+
shared_context "monetize matcher" do
|
24
19
|
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
it "matches model attribute without a '_cents' suffix by default" do
|
21
|
+
is_expected.to monetize(:price_cents)
|
22
|
+
end
|
28
23
|
|
29
|
-
|
30
|
-
|
31
|
-
|
24
|
+
it "matches model attribute specified by :as chain" do
|
25
|
+
is_expected.to monetize(:discount).as(:discount_value)
|
26
|
+
end
|
32
27
|
|
33
|
-
|
34
|
-
|
35
|
-
|
28
|
+
it "matches model attribute with nil value specified by :allow_nil chain" do
|
29
|
+
is_expected.to monetize(:optional_price).allow_nil
|
30
|
+
end
|
36
31
|
|
37
|
-
|
38
|
-
|
39
|
-
|
32
|
+
it "matches nullable model attribute when tested instance has a non-nil value" do
|
33
|
+
is_expected.to monetize(:optional_price).allow_nil
|
34
|
+
end
|
35
|
+
|
36
|
+
it "matches model attribute with currency specified by :with_currency chain" do
|
37
|
+
is_expected.to monetize(:bonus_cents).with_currency(:gbp)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "does not match non existed attribute" do
|
41
|
+
is_expected.not_to monetize(:price_fake)
|
42
|
+
end
|
40
43
|
|
41
|
-
|
42
|
-
|
44
|
+
it "does not match wrong currency iso" do
|
45
|
+
is_expected.not_to monetize(:bonus_cents).with_currency(:usd)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "does not match wrong money attribute name" do
|
49
|
+
is_expected.not_to monetize(:bonus_cents).as(:bonussss)
|
50
|
+
end
|
43
51
|
end
|
44
52
|
|
45
|
-
|
53
|
+
describe "testing against an instance of the model class" do
|
46
54
|
subject { product }
|
55
|
+
include_context "monetize matcher"
|
56
|
+
end
|
47
57
|
|
48
|
-
|
58
|
+
describe "testing against the model class itself" do
|
59
|
+
subject { Product }
|
60
|
+
include_context "monetize matcher"
|
49
61
|
end
|
50
62
|
end
|
51
63
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: money-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Loupasakis
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-12-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: money
|
@@ -88,14 +88,14 @@ dependencies:
|
|
88
88
|
requirements:
|
89
89
|
- - "~>"
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
version: '
|
91
|
+
version: '3.0'
|
92
92
|
type: :development
|
93
93
|
prerelease: false
|
94
94
|
version_requirements: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
96
|
- - "~>"
|
97
97
|
- !ruby/object:Gem::Version
|
98
|
-
version: '
|
98
|
+
version: '3.0'
|
99
99
|
- !ruby/object:Gem::Dependency
|
100
100
|
name: database_cleaner
|
101
101
|
requirement: !ruby/object:Gem::Requirement
|
@@ -173,6 +173,7 @@ files:
|
|
173
173
|
- spec/dummy/config/initializers/session_store.rb
|
174
174
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
175
175
|
- spec/dummy/config/locales/en-GB.yml
|
176
|
+
- spec/dummy/config/locales/en-US.yml
|
176
177
|
- spec/dummy/config/locales/en.yml
|
177
178
|
- spec/dummy/config/mongoid.yml
|
178
179
|
- spec/dummy/config/routes.rb
|
@@ -185,6 +186,7 @@ files:
|
|
185
186
|
- spec/dummy/db/migrate/20120712202655_add_sale_price_cents_to_product.rb
|
186
187
|
- spec/dummy/db/migrate/20130124023419_add_price_in_a_range_cents_to_products.rb
|
187
188
|
- spec/dummy/db/migrate/20140110194016_add_validates_method_amount_cents_to_products.rb
|
189
|
+
- spec/dummy/db/migrate/20141005075025_add_aliased_attr_to_products.rb
|
188
190
|
- spec/dummy/db/schema.rb
|
189
191
|
- spec/dummy/db/structure.sql
|
190
192
|
- spec/dummy/public/404.html
|
@@ -257,6 +259,7 @@ test_files:
|
|
257
259
|
- spec/dummy/config/initializers/session_store.rb
|
258
260
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
259
261
|
- spec/dummy/config/locales/en-GB.yml
|
262
|
+
- spec/dummy/config/locales/en-US.yml
|
260
263
|
- spec/dummy/config/locales/en.yml
|
261
264
|
- spec/dummy/config/mongoid.yml
|
262
265
|
- spec/dummy/config/routes.rb
|
@@ -269,6 +272,7 @@ test_files:
|
|
269
272
|
- spec/dummy/db/migrate/20120712202655_add_sale_price_cents_to_product.rb
|
270
273
|
- spec/dummy/db/migrate/20130124023419_add_price_in_a_range_cents_to_products.rb
|
271
274
|
- spec/dummy/db/migrate/20140110194016_add_validates_method_amount_cents_to_products.rb
|
275
|
+
- spec/dummy/db/migrate/20141005075025_add_aliased_attr_to_products.rb
|
272
276
|
- spec/dummy/db/schema.rb
|
273
277
|
- spec/dummy/db/structure.sql
|
274
278
|
- spec/dummy/public/404.html
|