unidom-geo 1.5.5 → 1.5.6

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: 2a800ecbdfa7ba9afa35ecb9c89707d1eccbd67b
4
- data.tar.gz: d13c37c21338bdb3769d39bf76b3924dfbb9f9d2
3
+ metadata.gz: b07c69b43b6c4003e4188e19cc8761aaa3fc37c4
4
+ data.tar.gz: a99da5d86e8d086ea2ff4236ffa106547e2d2753
5
5
  SHA512:
6
- metadata.gz: d113f7659b2a15dda8f02805dfea9a3391c6b1d36891dc3d29886218d94cd1ab4f9f1903c28a8f3f0f02b55874341321ffb14de0d490997fde8c984f8d9ddd90
7
- data.tar.gz: aec5ee8c8159785862c822f084acf67e86d2274ffab4d42545fbda471da173060d91fdb1f345f1d1afca830cfcf37af14adb490bd0907aa6901f044a12f4edc9
6
+ metadata.gz: 91769c5cfae2ed16f1166c1e3eb67da2d037938bc2e82234a9d004637e0cc6e4c2f06e9d3f40fc419eb24e2ebd4c85aa12bf2da219eccea59c12c2b844c049d3
7
+ data.tar.gz: 99586e668b69e43456adba80618b34fbb8b8777e69ef051f2dd0f66c81eaf59992f88e7109609095002be52def426be693115417a55e8a373d07ca9f01d57044
data/README.md CHANGED
@@ -102,6 +102,8 @@ end
102
102
 
103
103
  ## RSpec examples
104
104
 
105
+ ### RSpec example manifest (run automatically)
106
+
105
107
  ```ruby
106
108
  # spec/models/unidom_spec.rb
107
109
  require 'unidom/geo/models_rspec'
@@ -112,3 +114,60 @@ require 'unidom/geo/types_rspec'
112
114
  # spec/validators/unidom_spec.rb
113
115
  require 'unidom/geo/validators_rspec'
114
116
  ```
117
+
118
+ ### RSpec shared examples (to be integrated)
119
+
120
+ ```ruby
121
+ # lib/unidom.rb
122
+ def initialize_unidom
123
+
124
+ Unidom::Party::Shop.class_eval do
125
+ include Unidom::Geo::Concerns::AsLocated
126
+ end
127
+
128
+ Unidom::Geo::China::Region.class_eval do
129
+ include Unidom::Geo::Concerns::AsRegion
130
+ end
131
+
132
+ end
133
+
134
+ # spec/rails_helper.rb
135
+ require 'unidom'
136
+ initialize_unidom
137
+
138
+ # spec/support/unidom_rspec_shared_examples.rb
139
+ require 'unidom/geo/rspec_shared_examples'
140
+
141
+ # spec/models/unidom/party/shop_spec.rb
142
+ describe Unidom::Party::Shop, type: :model do
143
+
144
+ context do
145
+
146
+ model_attributes = {
147
+ name: 'Some Shop'
148
+ }
149
+
150
+ it_behaves_like 'Unidom::Geo::Concerns::AsLocated', model_attributes
151
+
152
+ end
153
+
154
+ end
155
+
156
+ # spec/models/unidom/geo/china/region_spec.rb
157
+ describe Unidom::Geo::China::Region, type: :model do
158
+
159
+ context do
160
+
161
+ model_attributes = {
162
+ numeric_code: '999897',
163
+ name: 'Some Region',
164
+ scheme_id: SecureRandom.uuid,
165
+ scheme_type: 'Unidom::Geo::China::Scheme::Mock'
166
+ }
167
+
168
+ it_behaves_like 'Unidom::Geo::Concerns::AsRegion', model_attributes
169
+
170
+ end
171
+
172
+ end
173
+ ```
@@ -0,0 +1,17 @@
1
+ shared_examples 'Unidom::Geo::Concerns::AsLocated' do |model_attributes|
2
+
3
+ locating_1_attribtues = {
4
+ location_id: SecureRandom.uuid,
5
+ locator_id: SecureRandom.uuid,
6
+ locator_type: 'Unidom::Geo::Locator::Mock'
7
+ }
8
+
9
+ locating_2_attribtues = {
10
+ location_id: SecureRandom.uuid,
11
+ locator_id: SecureRandom.uuid,
12
+ locator_type: 'Unidom::Geo::Locator::Mock'
13
+ }
14
+
15
+ it_behaves_like 'has_many', model_attributes, :locatings, Unidom::Geo::Locating, [ locating_1_attribtues, locating_2_attribtues ]
16
+
17
+ end
@@ -0,0 +1,27 @@
1
+ shared_examples 'Unidom::Geo::Concerns::AsRegion' do |model_attributes|
2
+
3
+ location_1_attribtues = {
4
+ longitude: 120.000000,
5
+ latitude: 31.000000,
6
+ postal_address: '#1 Some Street',
7
+ postal_code: '969696',
8
+ minimum_longitude: 119.000000,
9
+ minimum_latitude: 30.000000,
10
+ maximum_longitude: 121.000000,
11
+ maximum_latitude: 32.000000
12
+ }
13
+
14
+ location_2_attribtues = {
15
+ longitude: 120.000000,
16
+ latitude: 31.000000,
17
+ postal_address: '#2 Some Street',
18
+ postal_code: '979797',
19
+ minimum_longitude: 119.000000,
20
+ minimum_latitude: 30.000000,
21
+ maximum_longitude: 121.000000,
22
+ maximum_latitude: 32.000000
23
+ }
24
+
25
+ it_behaves_like 'has_many', model_attributes, :locations, Unidom::Geo::Location, [ location_1_attribtues, location_2_attribtues ]
26
+
27
+ end
@@ -36,8 +36,10 @@ describe Unidom::Geo::Location, type: :model do
36
36
  it_behaves_like 'validates numericality', model_attributes, :maximum_longitude,
37
37
  range: -180..180, minimum_inclusive: true, maximum_inclusive: true, allow_blank: false
38
38
 
39
- it_behaves_like 'validates text', model_attributes, :postal_address, length: 2..described_class.columns_hash['postal_address'].limit
40
- it_behaves_like 'validates text', model_attributes, :postal_code, length: 3..described_class.columns_hash['postal_code'].limit
39
+ it_behaves_like 'validates text', model_attributes, :postal_address,
40
+ length: 2..described_class.columns_hash['postal_address'].limit
41
+ it_behaves_like 'validates text', model_attributes, :postal_code,
42
+ length: 3..described_class.columns_hash['postal_code'].limit
41
43
 
42
44
  locating_1_attributes = {
43
45
  located_id: SecureRandom.uuid,
@@ -0,0 +1,2 @@
1
+ require 'rspec/models/unidom/geo/concerns/as_located_shared_examples'
2
+ require 'rspec/models/unidom/geo/concerns/as_region_shared_examples'
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Geo
3
- VERSION = '1.5.5'.freeze
3
+ VERSION = '1.5.6'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-geo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.5
4
+ version: 1.5.6
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-15 00:00:00.000000000 Z
11
+ date: 2017-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -52,12 +52,15 @@ files:
52
52
  - config/routes.rb
53
53
  - db/migrate/20010401000000_create_unidom_locations.rb
54
54
  - db/migrate/20010402000000_create_unidom_locatings.rb
55
+ - lib/rspec/models/unidom/geo/concerns/as_located_shared_examples.rb
56
+ - lib/rspec/models/unidom/geo/concerns/as_region_shared_examples.rb
55
57
  - lib/rspec/models/unidom/geo/locating_spec.rb
56
58
  - lib/rspec/models/unidom/geo/location_spec.rb
57
59
  - lib/tasks/geo_tasks.rake
58
60
  - lib/unidom/geo.rb
59
61
  - lib/unidom/geo/engine.rb
60
62
  - lib/unidom/geo/models_rspec.rb
63
+ - lib/unidom/geo/rspec_shared_examples.rb
61
64
  - lib/unidom/geo/types_rspec.rb
62
65
  - lib/unidom/geo/validators_rspec.rb
63
66
  - lib/unidom/geo/version.rb