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.
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
@@ -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
- it "matches model attribute specified by :as chain" do
22
- product.should monetize(:discount).as(:discount_value)
23
- end
18
+ shared_context "monetize matcher" do
24
19
 
25
- it "matches model attribute with nil value specified by :allow_nil chain" do
26
- product.should monetize(:optional_price).allow_nil
27
- end
20
+ it "matches model attribute without a '_cents' suffix by default" do
21
+ is_expected.to monetize(:price_cents)
22
+ end
28
23
 
29
- it "matches model attribute with currency specified by :with_currency chain" do
30
- product.should monetize(:bonus_cents).with_currency(:gbp)
31
- end
24
+ it "matches model attribute specified by :as chain" do
25
+ is_expected.to monetize(:discount).as(:discount_value)
26
+ end
32
27
 
33
- it "does not match non existed attribute" do
34
- product.should_not monetize(:price_fake)
35
- end
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
- it "does not match wrong currency iso" do
38
- product.should_not monetize(:bonus_cents).with_currency(:usd)
39
- end
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
- it "does not match wrong money attribute name" do
42
- product.should_not monetize(:bonus_cents).as(:bonussss)
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
- context "using subject" do
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
- it { should monetize(:price_cents) }
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.0.0
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-10-31 00:00:00.000000000 Z
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: '2.10'
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: '2.10'
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