unidom-price 1.7.2 → 1.7.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d8e07cb197dec510fdda3a27bd6464d2f547b4e
4
- data.tar.gz: 900df89838b0b385301f292061baf37948a2fcd7
3
+ metadata.gz: 7a7337d5ade7493a3ef1aadc3f8222d442a5b781
4
+ data.tar.gz: 2a1ad1ac2acbf147d7e7e2e9857d104de4cdbed5
5
5
  SHA512:
6
- metadata.gz: 7193bf76fec2a1de5394695d312fbc2c4621d63a2c0035ec91f07271e082efad4c197e8a60a46cfe6b527167e0b25c94eb42e173ba7571d0d0a1408729db832c
7
- data.tar.gz: 61a7bf28d4a74b35a780a1ccb42b0c16bdf6ada132818d7b0b68265daeb730d7a20d8416d0942f7f73fe68a5be5c34c4d00d889aebcfe2d59fdaa5edde2bd56a
6
+ metadata.gz: 1ca6806c02dd96e1abd5737cdf63a89eb5b61042e096a61150606b65d512789e173575f1baef7f8a9cf39ca35e3a694fa815508b6cd6502a5f9f885ed69f4711
7
+ data.tar.gz: c3bb8bd441a59d66f97f1bfcdbfca0dfd1a9d63e27af970cbb874f89e07accac0fcc3fa8dcebaf77c12e37af66f1accb4acc5149aff3152fc3cb3540ed718465
data/README.md CHANGED
@@ -146,6 +146,8 @@ end
146
146
 
147
147
  ## RSpec examples
148
148
 
149
+ ### RSpec example manifest (run automatically)
150
+
149
151
  ```ruby
150
152
  # spec/models/unidom_spec.rb
151
153
  require 'unidom/price/models_rspec'
@@ -156,3 +158,52 @@ require 'unidom/price/types_rspec'
156
158
  # spec/validators/unidom_spec.rb
157
159
  require 'unidom/price/validators_rspec'
158
160
  ```
161
+
162
+ ### RSpec shared examples (to be integrated)
163
+
164
+ ```ruby
165
+ # lib/unidom.rb
166
+ def initialize_unidom
167
+
168
+ Unidom::Party::Person.class_eval do
169
+ include Unidom::Price::Concerns::AsPricer
170
+ end
171
+
172
+ Unidom::Product::Product.class_eval do
173
+ include Unidom::Price::Concerns::AsPriced
174
+ end
175
+
176
+ end
177
+
178
+ # spec/rails_helper.rb
179
+ require 'unidom'
180
+ initialize_unidom
181
+
182
+ # spec/support/unidom_rspec_shared_examples.rb
183
+ require 'unidom/price/rspec_shared_examples'
184
+
185
+ # spec/models/unidom/party/person_spec.rb
186
+ describe Unidom::Party::Person do
187
+
188
+ model_attribtues = {
189
+ name: 'Tim'
190
+ }
191
+
192
+ it_behaves_like 'Unidom::Price::Concerns::AsPricer', model_attribtues
193
+
194
+ end
195
+
196
+ # spec/models/unidom/position/post_spec.rb
197
+ describe Unidom::Product::Product do
198
+
199
+ model_attribtues = {
200
+ name: 'Model X',
201
+ abbreviation: 'MX',
202
+ measurement_unit: 'set',
203
+ packing_norm: '1 per 1'
204
+ }
205
+
206
+ it_behaves_like 'Unidom::Price::Concerns::AsPriced', model_attribtues
207
+
208
+ end
209
+ ```
@@ -0,0 +1,17 @@
1
+ shared_examples 'Unidom::Price::Concerns::AsPriced' do |model_attributes|
2
+
3
+ price_1_attribtues = {
4
+ pricer_id: SecureRandom.uuid,
5
+ pricer_type: 'Unidom::Price::Pricer::Mock',
6
+ amount: 10.00
7
+ }
8
+
9
+ price_2_attribtues = {
10
+ pricer_id: SecureRandom.uuid,
11
+ pricer_type: 'Unidom::Price::Pricer::Mock',
12
+ amount: 21.00
13
+ }
14
+
15
+ it_behaves_like 'has_many', model_attributes, :prices, Unidom::Price::Price, [ price_1_attribtues, price_2_attribtues ]
16
+
17
+ end
@@ -0,0 +1,17 @@
1
+ shared_examples 'Unidom::Price::Concerns::AsPricer' do |model_attributes|
2
+
3
+ price_1_attribtues = {
4
+ priced_id: SecureRandom.uuid,
5
+ priced_type: 'Unidom::Price::Priced::Mock',
6
+ amount: 10.00
7
+ }
8
+
9
+ price_2_attribtues = {
10
+ priced_id: SecureRandom.uuid,
11
+ priced_type: 'Unidom::Price::Priced::Mock',
12
+ amount: 21.00
13
+ }
14
+
15
+ it_behaves_like 'has_many', model_attributes, :pricings, Unidom::Price::Price, [ price_1_attribtues, price_2_attribtues ]
16
+
17
+ end
@@ -0,0 +1,2 @@
1
+ require 'rspec/models/unidom/price/concerns/as_priced_shared_examples'
2
+ require 'rspec/models/unidom/price/concerns/as_pricer_shared_examples'
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Price
3
- VERSION = '1.7.2'.freeze
3
+ VERSION = '1.7.3'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-price
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.2
4
+ version: 1.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Topbit Du
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-05 00:00:00.000000000 Z
11
+ date: 2017-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -54,6 +54,8 @@ files:
54
54
  - config/locales/enum.zh-CN.yml
55
55
  - config/routes.rb
56
56
  - db/migrate/20020301000000_create_unidom_prices.rb
57
+ - lib/rspec/models/unidom/price/concerns/as_priced_shared_examples.rb
58
+ - lib/rspec/models/unidom/price/concerns/as_pricer_shared_examples.rb
57
59
  - lib/rspec/models/unidom/price/price_spec.rb
58
60
  - lib/rspec/types/unidom/price/calculation_spec.rb
59
61
  - lib/rspec/types/unidom/price/charging_spec.rb
@@ -62,6 +64,7 @@ files:
62
64
  - lib/unidom/price.rb
63
65
  - lib/unidom/price/engine.rb
64
66
  - lib/unidom/price/models_rspec.rb
67
+ - lib/unidom/price/rspec_shared_examples.rb
65
68
  - lib/unidom/price/types_rspec.rb
66
69
  - lib/unidom/price/validators_rspec.rb
67
70
  - lib/unidom/price/version.rb