pinpoint 0.4.0 → 0.4.1
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 +7 -0
- data/README.md +2 -0
- data/Rakefile +1 -1
- data/lib/pinpoint/address.rb +27 -26
- data/lib/pinpoint/config/patterns.rb +1 -1
- data/lib/pinpoint/config/us_states.rb +3 -3
- data/lib/pinpoint/format.rb +1 -1
- data/lib/pinpoint/format/file.rb +1 -2
- data/lib/pinpoint/format/list.rb +2 -2
- data/lib/pinpoint/format/parser.rb +0 -1
- data/lib/pinpoint/format/style.rb +3 -4
- data/lib/pinpoint/format/token.rb +1 -1
- data/lib/pinpoint/format/token_list.rb +2 -3
- data/lib/pinpoint/format/tokenizer.rb +16 -16
- data/lib/pinpoint/formatter.rb +1 -2
- data/lib/pinpoint/mapable.rb +2 -3
- data/lib/pinpoint/mapable_services/google_maps.rb +0 -1
- data/lib/pinpoint/mapable_services/mapquest.rb +0 -1
- data/lib/pinpoint/mapable_services/yahoo_maps.rb +0 -1
- data/lib/pinpoint/model_support.rb +3 -3
- data/lib/pinpoint/version.rb +1 -1
- data/spec/address_spec.rb +103 -103
- data/spec/format/file_spec.rb +5 -5
- data/spec/format/list_spec.rb +7 -7
- data/spec/format/parser_spec.rb +12 -12
- data/spec/format/style_spec.rb +19 -19
- data/spec/format/token_set_spec.rb +8 -8
- data/spec/format/token_spec.rb +9 -9
- data/spec/format/tokenizer_spec.rb +41 -41
- data/spec/format_spec.rb +11 -11
- data/spec/formatter_spec.rb +46 -43
- data/spec/mapable_services/google_maps_spec.rb +6 -6
- data/spec/mapable_services/mapquest_spec.rb +6 -6
- data/spec/mapable_services/yahoo_maps_spec.rb +6 -6
- data/spec/mapable_spec.rb +8 -8
- data/spec/model_support_spec.rb +143 -110
- data/spec/spec_helper.rb +1 -2
- data/spec/support/focused.rb +2 -2
- data/spec/support/pending.rb +1 -1
- data/spec/validations_spec.rb +57 -60
- metadata +39 -50
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'pinpoint/mapable_services/google_maps'
|
3
3
|
|
4
4
|
describe Pinpoint::MapableService::GoogleMaps do
|
@@ -7,11 +7,11 @@ describe Pinpoint::MapableService::GoogleMaps do
|
|
7
7
|
location_name: 'name with \\stuff/',
|
8
8
|
location: 'location with \\stuff/')
|
9
9
|
|
10
|
-
map_url.
|
11
|
-
'http://maps.google.com?q='
|
12
|
-
'location+with+%5Cstuff%2F'
|
13
|
-
'+'
|
14
|
-
'%28name+with+%5Cstuff%2F%29'
|
10
|
+
expect(map_url).to eql(
|
11
|
+
'http://maps.google.com?q=' \
|
12
|
+
'location+with+%5Cstuff%2F' \
|
13
|
+
'+' \
|
14
|
+
'%28name+with+%5Cstuff%2F%29',
|
15
15
|
)
|
16
16
|
end
|
17
17
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'pinpoint/mapable_services/mapquest'
|
3
3
|
|
4
4
|
describe Pinpoint::MapableService::Mapquest do
|
@@ -7,11 +7,11 @@ describe Pinpoint::MapableService::Mapquest do
|
|
7
7
|
location_name: 'name with \\stuff/',
|
8
8
|
location: 'location with \\stuff/')
|
9
9
|
|
10
|
-
map_url.
|
11
|
-
'http://mapquest.com?q='
|
12
|
-
'location+with+%5Cstuff%2F'
|
13
|
-
'+'
|
14
|
-
'%28name+with+%5Cstuff%2F%29'
|
10
|
+
expect(map_url).to eql(
|
11
|
+
'http://mapquest.com?q=' \
|
12
|
+
'location+with+%5Cstuff%2F' \
|
13
|
+
'+' \
|
14
|
+
'%28name+with+%5Cstuff%2F%29',
|
15
15
|
)
|
16
16
|
end
|
17
17
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'pinpoint/mapable_services/yahoo_maps'
|
3
3
|
|
4
4
|
describe Pinpoint::MapableService::YahooMaps do
|
@@ -7,11 +7,11 @@ describe Pinpoint::MapableService::YahooMaps do
|
|
7
7
|
location_name: 'name with \\stuff/',
|
8
8
|
location: 'location with \\stuff/')
|
9
9
|
|
10
|
-
map_url.
|
11
|
-
'http://maps.yahoo.com#q='
|
12
|
-
'location+with+%5Cstuff%2F'
|
13
|
-
'&tt='
|
14
|
-
'name+with+%5Cstuff%2F'
|
10
|
+
expect(map_url).to eql(
|
11
|
+
'http://maps.yahoo.com#q=' \
|
12
|
+
'location+with+%5Cstuff%2F' \
|
13
|
+
'&tt=' \
|
14
|
+
'name+with+%5Cstuff%2F',
|
15
15
|
)
|
16
16
|
end
|
17
17
|
end
|
data/spec/mapable_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'pinpoint/mapable'
|
3
3
|
|
4
4
|
class MyMapableClass
|
@@ -9,14 +9,14 @@ describe Pinpoint::Mapable do
|
|
9
9
|
let(:mapable) { MyMapableClass.new }
|
10
10
|
|
11
11
|
it 'can locate the map URL for itself via a given service' do
|
12
|
-
Pinpoint::MapableService::GoogleMaps.
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
allow(Pinpoint::MapableService::GoogleMaps).to receive(:map_url).
|
13
|
+
with(location_name: 'my_name',
|
14
|
+
location: 'my_location').
|
15
|
+
and_return('map_url')
|
16
16
|
|
17
|
-
mapable.
|
18
|
-
mapable.
|
17
|
+
allow(mapable).to receive(:to_s).and_return 'my_location'
|
18
|
+
allow(mapable).to receive(:name).and_return 'my_name'
|
19
19
|
|
20
|
-
mapable.map_url(:
|
20
|
+
mapable.map_url(via: :google_maps)
|
21
21
|
end
|
22
22
|
end
|
data/spec/model_support_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'pinpoint/model_support'
|
3
3
|
|
4
4
|
class PinpointableAccessorClass
|
@@ -45,89 +45,105 @@ describe Pinpoint::ModelSupport do
|
|
45
45
|
|
46
46
|
context 'when only a composed name is passed in' do
|
47
47
|
let(:pinpointable_class) { PinpointableAccessorClassWithPrefixedFields }
|
48
|
-
let(:pinpointable)
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
48
|
+
let(:pinpointable) do
|
49
|
+
pinpointable_class.new(
|
50
|
+
my_address_name: 'name',
|
51
|
+
my_address_street_and_premises: 'street',
|
52
|
+
my_address_city: 'city',
|
53
|
+
my_address_state: 'state',
|
54
|
+
my_address_county: 'county',
|
55
|
+
my_address_postal_code: 'postal_code',
|
56
|
+
my_address_country: 'country',
|
57
|
+
my_address_latitude: 'latitude',
|
58
|
+
my_address_longitude: 'longitude')
|
59
|
+
end
|
58
60
|
|
59
61
|
it 'can add a reader to a class' do
|
60
62
|
model_support_module.define_address_accessors(pinpointable_class,
|
61
63
|
field_name: :my_address)
|
62
64
|
|
63
|
-
pinpointable.
|
65
|
+
expect(pinpointable).to respond_to :my_address
|
64
66
|
end
|
65
67
|
|
66
68
|
it 'can compose an Address with the proper values from the model' do
|
67
69
|
model_support_module.define_address_accessors(pinpointable_class,
|
68
70
|
field_name: :my_address)
|
69
71
|
|
70
|
-
Pinpoint::Address.
|
71
|
-
name: 'name',
|
72
|
-
street_and_premises: 'street',
|
73
|
-
city: 'city',
|
74
|
-
state: 'state',
|
75
|
-
county: 'county',
|
76
|
-
postal_code: 'postal_code',
|
77
|
-
country: 'country',
|
78
|
-
latitude: 'latitude',
|
79
|
-
longitude: 'longitude'
|
80
|
-
)
|
72
|
+
allow(Pinpoint::Address).to receive(:new)
|
81
73
|
|
82
74
|
pinpointable.my_address
|
75
|
+
|
76
|
+
expect(Pinpoint::Address).to have_received(:new).with(
|
77
|
+
name: 'name',
|
78
|
+
street_and_premises: 'street',
|
79
|
+
city: 'city',
|
80
|
+
state: 'state',
|
81
|
+
county: 'county',
|
82
|
+
postal_code: 'postal_code',
|
83
|
+
country: 'country',
|
84
|
+
latitude: 'latitude',
|
85
|
+
longitude: 'longitude',
|
86
|
+
)
|
83
87
|
end
|
84
88
|
|
85
89
|
it 'can deconstruct an Address into its component pieces' do
|
86
90
|
model_support_module.define_address_accessors(pinpointable_class,
|
87
91
|
field_name: :my_address)
|
88
92
|
|
89
|
-
address = Pinpoint::Address.new(name:
|
90
|
-
street_and_premises:
|
91
|
-
city:
|
92
|
-
state:
|
93
|
-
county:
|
94
|
-
postal_code:
|
95
|
-
country:
|
96
|
-
latitude:
|
97
|
-
longitude:
|
98
|
-
|
99
|
-
pinpointable.
|
100
|
-
pinpointable.
|
101
|
-
pinpointable.
|
102
|
-
pinpointable.
|
103
|
-
pinpointable.
|
104
|
-
pinpointable.
|
105
|
-
pinpointable.
|
106
|
-
pinpointable.
|
107
|
-
pinpointable.
|
93
|
+
address = Pinpoint::Address.new(name: 'name',
|
94
|
+
street_and_premises: 'street',
|
95
|
+
city: 'city',
|
96
|
+
state: 'state',
|
97
|
+
county: 'county',
|
98
|
+
postal_code: 'postal_code',
|
99
|
+
country: 'country',
|
100
|
+
latitude: 'latitude',
|
101
|
+
longitude: 'longitude')
|
102
|
+
|
103
|
+
allow(pinpointable).to receive :my_address_name=
|
104
|
+
allow(pinpointable).to receive :my_address_street_and_premises=
|
105
|
+
allow(pinpointable).to receive :my_address_city=
|
106
|
+
allow(pinpointable).to receive :my_address_state=
|
107
|
+
allow(pinpointable).to receive :my_address_county=
|
108
|
+
allow(pinpointable).to receive :my_address_postal_code=
|
109
|
+
allow(pinpointable).to receive :my_address_country=
|
110
|
+
allow(pinpointable).to receive :my_address_latitude=
|
111
|
+
allow(pinpointable).to receive :my_address_longitude=
|
108
112
|
|
109
113
|
pinpointable.my_address = address
|
114
|
+
|
115
|
+
expect(pinpointable).to have_received(:my_address_name=).with('name')
|
116
|
+
expect(pinpointable).to have_received(:my_address_street_and_premises=).with('street')
|
117
|
+
expect(pinpointable).to have_received(:my_address_city=).with('city')
|
118
|
+
expect(pinpointable).to have_received(:my_address_state=).with('state')
|
119
|
+
expect(pinpointable).to have_received(:my_address_county=).with('county')
|
120
|
+
expect(pinpointable).to have_received(:my_address_postal_code=).with('postal_code')
|
121
|
+
expect(pinpointable).to have_received(:my_address_country=).with('country')
|
122
|
+
expect(pinpointable).to have_received(:my_address_latitude=).with('latitude')
|
123
|
+
expect(pinpointable).to have_received(:my_address_longitude=).with('longitude')
|
110
124
|
end
|
111
125
|
end
|
112
126
|
|
113
127
|
context 'when a composed name is passed in along with a prefix' do
|
114
128
|
let(:pinpointable_class) { PinpointableAccessorClassWithPrefixedFields }
|
115
|
-
let(:pinpointable)
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
129
|
+
let(:pinpointable) do
|
130
|
+
pinpointable_class.new(my_address_name: 'name',
|
131
|
+
my_address_street_and_premises: 'street',
|
132
|
+
my_address_city: 'city',
|
133
|
+
my_address_state: 'state',
|
134
|
+
my_address_county: 'county',
|
135
|
+
my_address_postal_code: 'postal_code',
|
136
|
+
my_address_country: 'country',
|
137
|
+
my_address_latitude: 'latitude',
|
138
|
+
my_address_longitude: 'longitude')
|
139
|
+
end
|
124
140
|
|
125
141
|
it 'can add a reader to a class' do
|
126
142
|
model_support_module.define_address_accessors(pinpointable_class,
|
127
143
|
field_name: :address,
|
128
144
|
prefix: :my_address)
|
129
145
|
|
130
|
-
pinpointable.
|
146
|
+
expect(pinpointable).to respond_to :address
|
131
147
|
end
|
132
148
|
|
133
149
|
it 'can compose an Address with the proper values from the model' do
|
@@ -135,16 +151,16 @@ describe Pinpoint::ModelSupport do
|
|
135
151
|
field_name: :address,
|
136
152
|
prefix: :my_address)
|
137
153
|
|
138
|
-
Pinpoint::Address.
|
139
|
-
name:
|
140
|
-
street_and_premises:
|
141
|
-
city:
|
142
|
-
state:
|
143
|
-
county:
|
144
|
-
postal_code:
|
145
|
-
country:
|
146
|
-
latitude:
|
147
|
-
longitude:
|
154
|
+
allow(Pinpoint::Address).to receive(:new).with(
|
155
|
+
name: 'name',
|
156
|
+
street_and_premises: 'street',
|
157
|
+
city: 'city',
|
158
|
+
state: 'state',
|
159
|
+
county: 'county',
|
160
|
+
postal_code: 'postal_code',
|
161
|
+
country: 'country',
|
162
|
+
latitude: 'latitude',
|
163
|
+
longitude: 'longitude',
|
148
164
|
)
|
149
165
|
|
150
166
|
pinpointable.address
|
@@ -155,47 +171,59 @@ describe Pinpoint::ModelSupport do
|
|
155
171
|
field_name: :address,
|
156
172
|
prefix: :my_address)
|
157
173
|
|
158
|
-
address = Pinpoint::Address.new(name:
|
159
|
-
street_and_premises:
|
160
|
-
city:
|
161
|
-
state:
|
162
|
-
county:
|
163
|
-
postal_code:
|
164
|
-
country:
|
165
|
-
latitude:
|
166
|
-
longitude:
|
167
|
-
|
168
|
-
pinpointable.
|
169
|
-
pinpointable.
|
170
|
-
pinpointable.
|
171
|
-
pinpointable.
|
172
|
-
pinpointable.
|
173
|
-
pinpointable.
|
174
|
-
pinpointable.
|
175
|
-
pinpointable.
|
176
|
-
pinpointable.
|
174
|
+
address = Pinpoint::Address.new(name: 'name',
|
175
|
+
street_and_premises: 'street',
|
176
|
+
city: 'city',
|
177
|
+
state: 'state',
|
178
|
+
county: 'county',
|
179
|
+
postal_code: 'postal_code',
|
180
|
+
country: 'country',
|
181
|
+
latitude: 'latitude',
|
182
|
+
longitude: 'longitude')
|
183
|
+
|
184
|
+
allow(pinpointable).to receive :my_address_name=
|
185
|
+
allow(pinpointable).to receive :my_address_street_and_premises=
|
186
|
+
allow(pinpointable).to receive :my_address_city=
|
187
|
+
allow(pinpointable).to receive :my_address_state=
|
188
|
+
allow(pinpointable).to receive :my_address_county=
|
189
|
+
allow(pinpointable).to receive :my_address_postal_code=
|
190
|
+
allow(pinpointable).to receive :my_address_country=
|
191
|
+
allow(pinpointable).to receive :my_address_latitude=
|
192
|
+
allow(pinpointable).to receive :my_address_longitude=
|
177
193
|
|
178
194
|
pinpointable.address = address
|
195
|
+
|
196
|
+
expect(pinpointable).to have_received(:my_address_name=).with('name')
|
197
|
+
expect(pinpointable).to have_received(:my_address_street_and_premises=).with('street')
|
198
|
+
expect(pinpointable).to have_received(:my_address_city=).with('city')
|
199
|
+
expect(pinpointable).to have_received(:my_address_state=).with('state')
|
200
|
+
expect(pinpointable).to have_received(:my_address_county=).with('county')
|
201
|
+
expect(pinpointable).to have_received(:my_address_postal_code=).with('postal_code')
|
202
|
+
expect(pinpointable).to have_received(:my_address_country=).with('country')
|
203
|
+
expect(pinpointable).to have_received(:my_address_latitude=).with('latitude')
|
204
|
+
expect(pinpointable).to have_received(:my_address_longitude=).with('longitude')
|
179
205
|
end
|
180
206
|
end
|
181
207
|
|
182
208
|
context 'when an object is referenced which does not implement all of the fields' do
|
183
209
|
let(:pinpointable_class) { PinpointableAccessorClassWithIncompleteFields }
|
184
|
-
let(:pinpointable)
|
185
|
-
|
186
|
-
|
187
|
-
|
210
|
+
let(:pinpointable) do
|
211
|
+
pinpointable_class.new(name: 'name',
|
212
|
+
street_and_premises: 'street',
|
213
|
+
city: 'city',
|
214
|
+
state: 'state')
|
215
|
+
end
|
188
216
|
|
189
217
|
it 'can compose an Address with the proper values from the model' do
|
190
218
|
model_support_module.define_address_accessors(pinpointable_class,
|
191
|
-
field_name:
|
192
|
-
prefix:
|
193
|
-
|
194
|
-
Pinpoint::Address.
|
195
|
-
name:
|
196
|
-
street_and_premises:
|
197
|
-
city:
|
198
|
-
state:
|
219
|
+
field_name: :address,
|
220
|
+
prefix: false)
|
221
|
+
|
222
|
+
allow(Pinpoint::Address).to receive(:new).with(
|
223
|
+
name: 'name',
|
224
|
+
street_and_premises: 'street',
|
225
|
+
city: 'city',
|
226
|
+
state: 'state',
|
199
227
|
)
|
200
228
|
|
201
229
|
pinpointable.address
|
@@ -203,25 +231,30 @@ describe Pinpoint::ModelSupport do
|
|
203
231
|
|
204
232
|
it 'can deconstruct an Address into its component pieces' do
|
205
233
|
model_support_module.define_address_accessors(pinpointable_class,
|
206
|
-
field_name:
|
207
|
-
prefix:
|
208
|
-
|
209
|
-
address = Pinpoint::Address.new(name:
|
210
|
-
street_and_premises:
|
211
|
-
city:
|
212
|
-
state:
|
213
|
-
county:
|
214
|
-
postal_code:
|
215
|
-
country:
|
216
|
-
latitude:
|
217
|
-
longitude:
|
218
|
-
|
219
|
-
pinpointable.
|
220
|
-
pinpointable.
|
221
|
-
pinpointable.
|
222
|
-
pinpointable.
|
234
|
+
field_name: :address,
|
235
|
+
prefix: false)
|
236
|
+
|
237
|
+
address = Pinpoint::Address.new(name: 'name',
|
238
|
+
street_and_premises: 'street',
|
239
|
+
city: 'city',
|
240
|
+
state: 'state',
|
241
|
+
county: 'county',
|
242
|
+
postal_code: 'postal_code',
|
243
|
+
country: 'country',
|
244
|
+
latitude: 'latitude',
|
245
|
+
longitude: 'longitude')
|
246
|
+
|
247
|
+
allow(pinpointable).to receive :name=
|
248
|
+
allow(pinpointable).to receive :street_and_premises=
|
249
|
+
allow(pinpointable).to receive :city=
|
250
|
+
allow(pinpointable).to receive :state=
|
223
251
|
|
224
252
|
pinpointable.address = address
|
253
|
+
|
254
|
+
expect(pinpointable).to have_received(:name=).with('name')
|
255
|
+
expect(pinpointable).to have_received(:street_and_premises=).with('street')
|
256
|
+
expect(pinpointable).to have_received(:city=).with('city')
|
257
|
+
expect(pinpointable).to have_received(:state=).with('state')
|
225
258
|
end
|
226
259
|
end
|
227
260
|
|
data/spec/spec_helper.rb
CHANGED
data/spec/support/focused.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
RSpec.configure do |config|
|
2
2
|
# Configure RSpec to run focused specs, and also respect the alias 'fit' for focused specs
|
3
3
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
4
|
-
config.filter_run :
|
5
|
-
config.alias_example_to :fit, :
|
4
|
+
config.filter_run focused: true
|
5
|
+
config.alias_example_to :fit, focused: true
|
6
6
|
config.run_all_when_everything_filtered = true
|
7
7
|
end
|
data/spec/support/pending.rb
CHANGED
data/spec/validations_spec.rb
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'valid_attribute'
|
3
|
-
require 'active_model'
|
4
|
-
require 'pinpoint'
|
1
|
+
require 'spec_helper'
|
5
2
|
|
6
3
|
class ValidatablePinpointable
|
7
4
|
include ActiveModel::Validations
|
@@ -29,7 +26,7 @@ class UnvalidatablePinpointable
|
|
29
26
|
:address_postal_code,
|
30
27
|
:address_country
|
31
28
|
|
32
|
-
pinpoint :address, :
|
29
|
+
pinpoint :address, prefix: :address
|
33
30
|
end
|
34
31
|
|
35
32
|
describe 'Pinpoint::Validations' do
|
@@ -37,60 +34,60 @@ describe 'Pinpoint::Validations' do
|
|
37
34
|
subject { ValidatablePinpointable.new }
|
38
35
|
|
39
36
|
describe '#address_name' do
|
40
|
-
it {
|
41
|
-
it {
|
37
|
+
it { expect(subject).to allow_value(nil, ('*' * 140)).for(:name) }
|
38
|
+
it { expect(subject).not_to allow_value(('*' * 141)).for(:name) }
|
42
39
|
end
|
43
40
|
|
44
41
|
describe '#address_state' do
|
45
|
-
it {
|
46
|
-
it {
|
42
|
+
it { expect(subject).to allow_value(nil, ('*' * 255)).for(:street_and_premises) }
|
43
|
+
it { expect(subject).not_to allow_value(('*' * 256)).for(:street_and_premises) }
|
47
44
|
end
|
48
45
|
|
49
46
|
describe '#address_city' do
|
50
|
-
it {
|
51
|
-
it {
|
47
|
+
it { expect(subject).to allow_value(nil, ('*' * 60)).for(:city) }
|
48
|
+
it { expect(subject).not_to allow_value(('*' * 61)).for(:city) }
|
52
49
|
end
|
53
50
|
|
54
51
|
describe '#address_street_and_premises' do
|
55
|
-
it {
|
56
|
-
it {
|
52
|
+
it { expect(subject).to allow_value(nil, '', 'NY', 'MO').for(:state) }
|
53
|
+
it { expect(subject).not_to allow_value('WP', 'NI', 'PO').for(:state) }
|
57
54
|
end
|
58
55
|
|
59
56
|
describe '#address_postal_code' do
|
60
|
-
it {
|
61
|
-
it {
|
57
|
+
it { expect(subject).to allow_value(nil, '', 12_345, 12_345 - 1234).for(:postal_code) }
|
58
|
+
it { expect(subject).not_to allow_value('asdf', '123456').for(:postal_code) }
|
62
59
|
end
|
63
60
|
|
64
|
-
context
|
65
|
-
before { subject.street_and_premises =
|
61
|
+
context 'when the street address is set' do
|
62
|
+
before { subject.street_and_premises = 'foo' }
|
66
63
|
|
67
|
-
it('the city should not be valid when blank') {
|
68
|
-
it('the state should not be valid when blank') {
|
69
|
-
it('the zip code should not be valid when blank') {
|
64
|
+
it('the city should not be valid when blank') { expect(subject).not_to allow_value(nil, '').for(:city) }
|
65
|
+
it('the state should not be valid when blank') { expect(subject).not_to allow_value(nil, '').for(:state) }
|
66
|
+
it('the zip code should not be valid when blank') { expect(subject).not_to allow_value(nil, '').for(:postal_code) }
|
70
67
|
end
|
71
68
|
|
72
|
-
context
|
73
|
-
before { subject.city =
|
69
|
+
context 'when the city is set' do
|
70
|
+
before { subject.city = 'foo' }
|
74
71
|
|
75
|
-
it('the street should not be valid when blank') {
|
76
|
-
it('the state should not be valid when blank') {
|
77
|
-
it('the zip code should not be valid when blank') {
|
72
|
+
it('the street should not be valid when blank') { expect(subject).not_to allow_value(nil, '').for(:street_and_premises) }
|
73
|
+
it('the state should not be valid when blank') { expect(subject).not_to allow_value(nil, '').for(:state) }
|
74
|
+
it('the zip code should not be valid when blank') { expect(subject).not_to allow_value(nil, '').for(:postal_code) }
|
78
75
|
end
|
79
76
|
|
80
|
-
context
|
81
|
-
before { subject.state =
|
77
|
+
context 'when the state is set' do
|
78
|
+
before { subject.state = 'FO' }
|
82
79
|
|
83
|
-
it('the street should not be valid when blank') {
|
84
|
-
it('the city should not be valid when blank') {
|
85
|
-
it('the zip code should not be valid when blank') {
|
80
|
+
it('the street should not be valid when blank') { expect(subject).not_to allow_value(nil, '').for(:street_and_premises) }
|
81
|
+
it('the city should not be valid when blank') { expect(subject).not_to allow_value(nil, '').for(:city) }
|
82
|
+
it('the zip code should not be valid when blank') { expect(subject).not_to allow_value(nil, '').for(:postal_code) }
|
86
83
|
end
|
87
84
|
|
88
|
-
context
|
89
|
-
before { subject.postal_code =
|
85
|
+
context 'when the zip is set' do
|
86
|
+
before { subject.postal_code = '12345' }
|
90
87
|
|
91
|
-
it('the street should not be valid when blank') {
|
92
|
-
it('the city should not be valid when blank') {
|
93
|
-
it('the state should not be valid when blank') {
|
88
|
+
it('the street should not be valid when blank') { expect(subject).not_to allow_value(nil, '').for(:street_and_premises) }
|
89
|
+
it('the city should not be valid when blank') { expect(subject).not_to allow_value(nil, '').for(:city) }
|
90
|
+
it('the state should not be valid when blank') { expect(subject).not_to allow_value(nil, '').for(:state) }
|
94
91
|
end
|
95
92
|
end
|
96
93
|
|
@@ -98,55 +95,55 @@ describe 'Pinpoint::Validations' do
|
|
98
95
|
subject { UnvalidatablePinpointable.new }
|
99
96
|
|
100
97
|
describe '#address_name' do
|
101
|
-
it {
|
98
|
+
it { expect(subject).to allow_value(('*' * 141)).for(:address_name) }
|
102
99
|
end
|
103
100
|
|
104
101
|
describe '#address_state' do
|
105
|
-
it {
|
102
|
+
it { expect(subject).to allow_value(('*' * 256)).for(:address_street_and_premises) }
|
106
103
|
end
|
107
104
|
|
108
105
|
describe '#address_city' do
|
109
|
-
it {
|
106
|
+
it { expect(subject).to allow_value(('*' * 61)).for(:address_city) }
|
110
107
|
end
|
111
108
|
|
112
109
|
describe '#address_street_and_premises' do
|
113
|
-
it {
|
110
|
+
it { expect(subject).to allow_value('WP', 'NI', 'PO').for(:address_state) }
|
114
111
|
end
|
115
112
|
|
116
113
|
describe '#address_postal_code' do
|
117
|
-
it {
|
114
|
+
it { expect(subject).to allow_value('asdf', '123456').for(:address_postal_code) }
|
118
115
|
end
|
119
116
|
|
120
|
-
context
|
121
|
-
before { subject.address_street_and_premises =
|
117
|
+
context 'when the street address is set' do
|
118
|
+
before { subject.address_street_and_premises = 'foo' }
|
122
119
|
|
123
|
-
it('the city should not be valid when blank') {
|
124
|
-
it('the state should not be valid when blank') {
|
125
|
-
it('the zip code should not be valid when blank') {
|
120
|
+
it('the city should not be valid when blank') { expect(subject).to allow_value(nil, '').for(:address_city) }
|
121
|
+
it('the state should not be valid when blank') { expect(subject).to allow_value(nil, '').for(:address_state) }
|
122
|
+
it('the zip code should not be valid when blank') { expect(subject).to allow_value(nil, '').for(:address_postal_code) }
|
126
123
|
end
|
127
124
|
|
128
|
-
context
|
129
|
-
before { subject.address_city =
|
125
|
+
context 'when the city is set' do
|
126
|
+
before { subject.address_city = 'foo' }
|
130
127
|
|
131
|
-
it('the street should not be valid when blank') {
|
132
|
-
it('the state should not be valid when blank') {
|
133
|
-
it('the zip code should not be valid when blank') {
|
128
|
+
it('the street should not be valid when blank') { expect(subject).to allow_value(nil, '').for(:address_street_and_premises) }
|
129
|
+
it('the state should not be valid when blank') { expect(subject).to allow_value(nil, '').for(:address_state) }
|
130
|
+
it('the zip code should not be valid when blank') { expect(subject).to allow_value(nil, '').for(:address_postal_code) }
|
134
131
|
end
|
135
132
|
|
136
|
-
context
|
137
|
-
before { subject.address_state =
|
133
|
+
context 'when the state is set' do
|
134
|
+
before { subject.address_state = 'FO' }
|
138
135
|
|
139
|
-
it('the street should not be valid when blank') {
|
140
|
-
it('the city should not be valid when blank') {
|
141
|
-
it('the zip code should not be valid when blank') {
|
136
|
+
it('the street should not be valid when blank') { expect(subject).to allow_value(nil, '').for(:address_street_and_premises) }
|
137
|
+
it('the city should not be valid when blank') { expect(subject).to allow_value(nil, '').for(:address_city) }
|
138
|
+
it('the zip code should not be valid when blank') { expect(subject).to allow_value(nil, '').for(:address_postal_code) }
|
142
139
|
end
|
143
140
|
|
144
|
-
context
|
145
|
-
before { subject.address_postal_code =
|
141
|
+
context 'when the zip is set' do
|
142
|
+
before { subject.address_postal_code = '12345' }
|
146
143
|
|
147
|
-
it('the street should not be valid when blank') {
|
148
|
-
it('the city should not be valid when blank') {
|
149
|
-
it('the state should not be valid when blank') {
|
144
|
+
it('the street should not be valid when blank') { expect(subject).to allow_value(nil, '').for(:address_street_and_premises) }
|
145
|
+
it('the city should not be valid when blank') { expect(subject).to allow_value(nil, '').for(:address_city) }
|
146
|
+
it('the state should not be valid when blank') { expect(subject).to allow_value(nil, '').for(:address_state) }
|
150
147
|
end
|
151
148
|
end
|
152
149
|
end
|