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.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +2 -0
  3. data/Rakefile +1 -1
  4. data/lib/pinpoint/address.rb +27 -26
  5. data/lib/pinpoint/config/patterns.rb +1 -1
  6. data/lib/pinpoint/config/us_states.rb +3 -3
  7. data/lib/pinpoint/format.rb +1 -1
  8. data/lib/pinpoint/format/file.rb +1 -2
  9. data/lib/pinpoint/format/list.rb +2 -2
  10. data/lib/pinpoint/format/parser.rb +0 -1
  11. data/lib/pinpoint/format/style.rb +3 -4
  12. data/lib/pinpoint/format/token.rb +1 -1
  13. data/lib/pinpoint/format/token_list.rb +2 -3
  14. data/lib/pinpoint/format/tokenizer.rb +16 -16
  15. data/lib/pinpoint/formatter.rb +1 -2
  16. data/lib/pinpoint/mapable.rb +2 -3
  17. data/lib/pinpoint/mapable_services/google_maps.rb +0 -1
  18. data/lib/pinpoint/mapable_services/mapquest.rb +0 -1
  19. data/lib/pinpoint/mapable_services/yahoo_maps.rb +0 -1
  20. data/lib/pinpoint/model_support.rb +3 -3
  21. data/lib/pinpoint/version.rb +1 -1
  22. data/spec/address_spec.rb +103 -103
  23. data/spec/format/file_spec.rb +5 -5
  24. data/spec/format/list_spec.rb +7 -7
  25. data/spec/format/parser_spec.rb +12 -12
  26. data/spec/format/style_spec.rb +19 -19
  27. data/spec/format/token_set_spec.rb +8 -8
  28. data/spec/format/token_spec.rb +9 -9
  29. data/spec/format/tokenizer_spec.rb +41 -41
  30. data/spec/format_spec.rb +11 -11
  31. data/spec/formatter_spec.rb +46 -43
  32. data/spec/mapable_services/google_maps_spec.rb +6 -6
  33. data/spec/mapable_services/mapquest_spec.rb +6 -6
  34. data/spec/mapable_services/yahoo_maps_spec.rb +6 -6
  35. data/spec/mapable_spec.rb +8 -8
  36. data/spec/model_support_spec.rb +143 -110
  37. data/spec/spec_helper.rb +1 -2
  38. data/spec/support/focused.rb +2 -2
  39. data/spec/support/pending.rb +1 -1
  40. data/spec/validations_spec.rb +57 -60
  41. metadata +39 -50
@@ -1,4 +1,4 @@
1
- require 'rspectacular'
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.should eql(
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 'rspectacular'
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.should eql(
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 'rspectacular'
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.should eql(
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
@@ -1,4 +1,4 @@
1
- require 'rspectacular'
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.should_receive(:map_url)
13
- .with(location_name: 'my_name',
14
- location: 'my_location')
15
- .and_return('map_url')
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.should_receive(:to_s).and_return 'my_location'
18
- mapable.should_receive(:name).and_return 'my_name'
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(:via => :google_maps)
20
+ mapable.map_url(via: :google_maps)
21
21
  end
22
22
  end
@@ -1,4 +1,4 @@
1
- require 'rspectacular'
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) { pinpointable_class.new(
49
- my_address_name: 'name',
50
- my_address_street_and_premises: 'street',
51
- my_address_city: 'city',
52
- my_address_state: 'state',
53
- my_address_county: 'county',
54
- my_address_postal_code: 'postal_code',
55
- my_address_country: 'country',
56
- my_address_latitude: 'latitude',
57
- my_address_longitude: 'longitude' ) }
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.should respond_to :my_address
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.should_receive(:new).with(
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: 'name',
90
- street_and_premises: 'street',
91
- city: 'city',
92
- state: 'state',
93
- county: 'county',
94
- postal_code: 'postal_code',
95
- country: 'country',
96
- latitude: 'latitude',
97
- longitude: 'longitude')
98
-
99
- pinpointable.should_receive :my_address_name=, :with => 'name'
100
- pinpointable.should_receive :my_address_street_and_premises=, :with => 'street'
101
- pinpointable.should_receive :my_address_city=, :with => 'city'
102
- pinpointable.should_receive :my_address_state=, :with => 'state'
103
- pinpointable.should_receive :my_address_county=, :with => 'county'
104
- pinpointable.should_receive :my_address_postal_code=, :with => 'postal_code'
105
- pinpointable.should_receive :my_address_country=, :with => 'country'
106
- pinpointable.should_receive :my_address_latitude=, :with => 'latitude'
107
- pinpointable.should_receive :my_address_longitude=, :with => 'longitude'
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) { pinpointable_class.new( my_address_name: 'name',
116
- my_address_street_and_premises: 'street',
117
- my_address_city: 'city',
118
- my_address_state: 'state',
119
- my_address_county: 'county',
120
- my_address_postal_code: 'postal_code',
121
- my_address_country: 'country',
122
- my_address_latitude: 'latitude',
123
- my_address_longitude: 'longitude' ) }
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.should respond_to :address
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.should_receive(:new).with(
139
- name: 'name',
140
- street_and_premises: 'street',
141
- city: 'city',
142
- state: 'state',
143
- county: 'county',
144
- postal_code: 'postal_code',
145
- country: 'country',
146
- latitude: 'latitude',
147
- longitude: '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: 'name',
159
- street_and_premises: 'street',
160
- city: 'city',
161
- state: 'state',
162
- county: 'county',
163
- postal_code: 'postal_code',
164
- country: 'country',
165
- latitude: 'latitude',
166
- longitude: 'longitude')
167
-
168
- pinpointable.should_receive :my_address_name=, :with => 'name'
169
- pinpointable.should_receive :my_address_street_and_premises=, :with => 'street'
170
- pinpointable.should_receive :my_address_city=, :with => 'city'
171
- pinpointable.should_receive :my_address_state=, :with => 'state'
172
- pinpointable.should_receive :my_address_county=, :with => 'county'
173
- pinpointable.should_receive :my_address_postal_code=, :with => 'postal_code'
174
- pinpointable.should_receive :my_address_country=, :with => 'country'
175
- pinpointable.should_receive :my_address_latitude=, :with => 'latitude'
176
- pinpointable.should_receive :my_address_longitude=, :with => 'longitude'
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) { pinpointable_class.new( name: 'name',
185
- street_and_premises: 'street',
186
- city: 'city',
187
- state: 'state' ) }
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: :address,
192
- prefix: false)
193
-
194
- Pinpoint::Address.should_receive(:new).with(
195
- name: 'name',
196
- street_and_premises: 'street',
197
- city: 'city',
198
- state: '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: :address,
207
- prefix: false)
208
-
209
- address = Pinpoint::Address.new(name: 'name',
210
- street_and_premises: 'street',
211
- city: 'city',
212
- state: 'state',
213
- county: 'county',
214
- postal_code: 'postal_code',
215
- country: 'country',
216
- latitude: 'latitude',
217
- longitude: 'longitude')
218
-
219
- pinpointable.should_receive :name=, :with => 'name'
220
- pinpointable.should_receive :street_and_premises=, :with => 'street'
221
- pinpointable.should_receive :city=, :with => 'city'
222
- pinpointable.should_receive :state=, :with => 'state'
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
 
@@ -1,4 +1,3 @@
1
- require 'rspectacular'
2
- require 'valid_attribute'
3
1
  require 'active_model'
2
+ require 'rspectacular'
4
3
  require 'pinpoint'
@@ -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 :focused => true
5
- config.alias_example_to :fit, :focused => true
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
@@ -1,4 +1,4 @@
1
1
  RSpec.configure do |config|
2
2
  # Configure RSpec to respect the alias 'pit' for pending specs
3
- config.alias_example_to :pit, :pending => true
3
+ config.alias_example_to :pit, pending: true
4
4
  end
@@ -1,7 +1,4 @@
1
- require 'rspectacular'
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, :prefix => :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 { should have_valid(:name).when nil, ('*' * 140) }
41
- it { should_not have_valid(:name).when ('*' * 141) }
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 { should have_valid(:street_and_premises).when nil, ('*' * 255) }
46
- it { should_not have_valid(:street_and_premises).when ('*' * 256) }
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 { should have_valid(:city).when nil, ('*' * 60) }
51
- it { should_not have_valid(:city).when ('*' * 61) }
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 { should have_valid(:state).when nil, '', 'NY', 'MO' }
56
- it { should_not have_valid(:state).when 'WP', 'NI', 'PO' }
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 { should have_valid(:postal_code).when nil, '', 12345, 12345-1234 }
61
- it { should_not have_valid(:postal_code).when 'asdf', '123456' }
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 "when the street address is set" do
65
- before { subject.street_and_premises = "foo" }
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') { should_not have_valid(:city).when nil, '' }
68
- it('the state should not be valid when blank') { should_not have_valid(:state).when nil, '' }
69
- it('the zip code should not be valid when blank') { should_not have_valid(:postal_code).when nil, '' }
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 "when the city is set" do
73
- before { subject.city = "foo" }
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') { should_not have_valid(:street_and_premises).when nil, '' }
76
- it('the state should not be valid when blank') { should_not have_valid(:state).when nil, '' }
77
- it('the zip code should not be valid when blank') { should_not have_valid(:postal_code).when nil, '' }
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 "when the state is set" do
81
- before { subject.state = "FO" }
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') { should_not have_valid(:street_and_premises).when nil, '' }
84
- it('the city should not be valid when blank') { should_not have_valid(:city).when nil, '' }
85
- it('the zip code should not be valid when blank') { should_not have_valid(:postal_code).when nil, '' }
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 "when the zip is set" do
89
- before { subject.postal_code = "12345" }
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') { should_not have_valid(:street_and_premises).when nil, '' }
92
- it('the city should not be valid when blank') { should_not have_valid(:city).when nil, '' }
93
- it('the state should not be valid when blank') { should_not have_valid(:state).when nil, '' }
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 { should have_valid(:address_name).when ('*' * 141) }
98
+ it { expect(subject).to allow_value(('*' * 141)).for(:address_name) }
102
99
  end
103
100
 
104
101
  describe '#address_state' do
105
- it { should have_valid(:address_street_and_premises).when ('*' * 256) }
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 { should have_valid(:address_city).when ('*' * 61) }
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 { should have_valid(:address_state).when 'WP', 'NI', 'PO' }
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 { should have_valid(:address_postal_code).when 'asdf', '123456' }
114
+ it { expect(subject).to allow_value('asdf', '123456').for(:address_postal_code) }
118
115
  end
119
116
 
120
- context "when the street address is set" do
121
- before { subject.address_street_and_premises = "foo" }
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') { should have_valid(:address_city).when nil, '' }
124
- it('the state should not be valid when blank') { should have_valid(:address_state).when nil, '' }
125
- it('the zip code should not be valid when blank') { should have_valid(:address_postal_code).when nil, '' }
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 "when the city is set" do
129
- before { subject.address_city = "foo" }
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') { should have_valid(:address_street_and_premises).when nil, '' }
132
- it('the state should not be valid when blank') { should have_valid(:address_state).when nil, '' }
133
- it('the zip code should not be valid when blank') { should have_valid(:address_postal_code).when nil, '' }
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 "when the state is set" do
137
- before { subject.address_state = "FO" }
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') { should have_valid(:address_street_and_premises).when nil, '' }
140
- it('the city should not be valid when blank') { should have_valid(:address_city).when nil, '' }
141
- it('the zip code should not be valid when blank') { should have_valid(:address_postal_code).when nil, '' }
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 "when the zip is set" do
145
- before { subject.address_postal_code = "12345" }
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') { should have_valid(:address_street_and_premises).when nil, '' }
148
- it('the city should not be valid when blank') { should have_valid(:address_city).when nil, '' }
149
- it('the state should not be valid when blank') { should have_valid(:address_state).when nil, '' }
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