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
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ec389cf558be0cf394dc052c78fcab7cead09b1f
|
4
|
+
data.tar.gz: 3196679d69559c65e2e325217fe59f5d6f2b0362
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ab7ec3591033e820b5123d6df82209929bcdf8103c3a99cf9fd60cdef7d0a773641093fa0449349821ec213e2b789d17e7dcd946dbfd2786e17ff59a0b424788
|
7
|
+
data.tar.gz: a337577be69629350c0efb96b54e3bfbf65067d8bd2810c04ccdd85aa75e392ddff02e7e71cb4301064ca419ee84e0db0a898f44eb5b0fd32af9778cfed2ccc6
|
data/README.md
CHANGED
@@ -5,6 +5,8 @@ Pinpoint
|
|
5
5
|
|
6
6
|
_(Un)conventional Address Composition for Ruby (and Rails)_
|
7
7
|
|
8
|
+
[](http://travis-ci.org/jfelchner/pinpoint) [](https://codeclimate.com/github/jfelchner/pinpoint) [](https://codeclimate.com/github/jfelchner/pinpoint)
|
9
|
+
|
8
10
|
Supported Rubies
|
9
11
|
--------------------------------
|
10
12
|
* MRI Ruby 1.9.2
|
data/Rakefile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
data/lib/pinpoint/address.rb
CHANGED
@@ -6,42 +6,42 @@ module Pinpoint
|
|
6
6
|
include Mapable
|
7
7
|
|
8
8
|
ATTRIBUTE_NAMES = [
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
9
|
+
:name,
|
10
|
+
:street_and_premises,
|
11
|
+
:city,
|
12
|
+
:state,
|
13
|
+
:county,
|
14
|
+
:postal_code,
|
15
|
+
:country,
|
16
|
+
:latitude,
|
17
|
+
:longitude,
|
18
|
+
]
|
19
19
|
|
20
20
|
attr_accessor *ATTRIBUTE_NAMES
|
21
21
|
|
22
22
|
# City Aliases
|
23
|
-
|
24
|
-
|
23
|
+
alias_method :locality, :city
|
24
|
+
alias_method :locality=, :city=
|
25
25
|
|
26
26
|
# Street Aliases
|
27
|
-
|
28
|
-
|
27
|
+
alias_method :street, :street_and_premises
|
28
|
+
alias_method :street=, :street_and_premises=
|
29
29
|
|
30
30
|
# State Aliases
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
alias_method :region, :state
|
32
|
+
alias_method :region=, :state=
|
33
|
+
alias_method :province, :state
|
34
|
+
alias_method :province=, :state=
|
35
35
|
|
36
36
|
# Zip Code Aliases
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
alias_method :zip_code, :postal_code
|
38
|
+
alias_method :zip_code=, :postal_code=
|
39
|
+
alias_method :zip, :postal_code
|
40
|
+
alias_method :zip=, :postal_code=
|
41
41
|
|
42
42
|
# County Aliases
|
43
|
-
|
44
|
-
|
43
|
+
alias_method :district, :county
|
44
|
+
alias_method :district=, :county=
|
45
45
|
|
46
46
|
def initialize(options = {})
|
47
47
|
options.each do |key, value|
|
@@ -69,11 +69,12 @@ module Pinpoint
|
|
69
69
|
blank?(country)
|
70
70
|
end
|
71
71
|
|
72
|
-
def to_s(options = { :
|
72
|
+
def to_s(options = { country: :us, format: :one_line })
|
73
73
|
Formatter.format(self, options)
|
74
74
|
end
|
75
75
|
|
76
|
-
|
76
|
+
private
|
77
|
+
|
77
78
|
def present?(value)
|
78
79
|
!blank?(value)
|
79
80
|
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
Pinpoint::US_STATES = %w
|
2
|
-
|
3
|
-
|
1
|
+
Pinpoint::US_STATES = %w{AK AL AR AZ CA CO CT DC DE FL GA HI IA ID IL IN KS KY LA MA MD
|
2
|
+
ME MI MN MO MS MT NC ND NE NH NJ NM NV NY OH OK OR PA RI SC SD TN TX UT VA VT
|
3
|
+
WA WI WV WY}
|
data/lib/pinpoint/format.rb
CHANGED
data/lib/pinpoint/format/file.rb
CHANGED
@@ -4,7 +4,6 @@ require 'pinpoint/format/style'
|
|
4
4
|
module Pinpoint
|
5
5
|
class Format
|
6
6
|
class File
|
7
|
-
|
8
7
|
##
|
9
8
|
# Public: Loads the format for the given country from the appropriate
|
10
9
|
# YAML file.
|
@@ -38,7 +37,7 @@ module Pinpoint
|
|
38
37
|
end
|
39
38
|
|
40
39
|
def self.raw_style_data(country)
|
41
|
-
YAML
|
40
|
+
YAML.load(format_yaml_contents(country))
|
42
41
|
end
|
43
42
|
end
|
44
43
|
end
|
data/lib/pinpoint/format/list.rb
CHANGED
@@ -4,7 +4,6 @@ require 'active_support/core_ext/string/output_safety'
|
|
4
4
|
module Pinpoint
|
5
5
|
class Format
|
6
6
|
class Style
|
7
|
-
|
8
7
|
##
|
9
8
|
# Public: Processes the style information gleaned from the Pinpoint YAML
|
10
9
|
# format and generates a Style from it.
|
@@ -17,7 +16,7 @@ module Pinpoint
|
|
17
16
|
# Returns a Pinpoint::Format::Style based on the information passed in.
|
18
17
|
#
|
19
18
|
def self.from_yaml(style_definition)
|
20
|
-
style =
|
19
|
+
style = new
|
21
20
|
style.send(:structure=, Format::Parser.new(style_definition).parse)
|
22
21
|
style
|
23
22
|
end
|
@@ -57,7 +56,7 @@ module Pinpoint
|
|
57
56
|
# Returns a String containing data from the context and String literals
|
58
57
|
#
|
59
58
|
def process(structure, context)
|
60
|
-
processed =
|
59
|
+
processed = ''.html_safe
|
61
60
|
|
62
61
|
structure.each_with_object(processed) do |token, result|
|
63
62
|
result << case token
|
@@ -70,7 +69,7 @@ module Pinpoint
|
|
70
69
|
end
|
71
70
|
end
|
72
71
|
|
73
|
-
processed.match(no_alphanumerics) ?
|
72
|
+
processed.match(no_alphanumerics) ? ''.html_safe : processed
|
74
73
|
end
|
75
74
|
|
76
75
|
def no_alphanumerics
|
@@ -3,7 +3,6 @@ require 'pinpoint/format/parse_error'
|
|
3
3
|
module Pinpoint
|
4
4
|
class Format
|
5
5
|
class TokenList < Array
|
6
|
-
|
7
6
|
##
|
8
7
|
# Public: Processes each item in the list by removing it and passing it to
|
9
8
|
# the block.
|
@@ -15,7 +14,7 @@ module Pinpoint
|
|
15
14
|
# Returns nothing
|
16
15
|
#
|
17
16
|
def process_each!
|
18
|
-
while size > 0
|
17
|
+
while size > 0
|
19
18
|
token = delete_at(0)
|
20
19
|
|
21
20
|
yield token
|
@@ -30,7 +29,7 @@ module Pinpoint
|
|
30
29
|
# 'group_start' tokens does not match the number of 'group_end' tokens.
|
31
30
|
#
|
32
31
|
def valid?
|
33
|
-
|
32
|
+
fail Pinpoint::Format::UnevenNestingError if group_start_count != group_end_count
|
34
33
|
|
35
34
|
true
|
36
35
|
end
|
@@ -30,7 +30,7 @@ module Pinpoint
|
|
30
30
|
# Returns nothing
|
31
31
|
#
|
32
32
|
def each
|
33
|
-
|
33
|
+
tokenable.reset
|
34
34
|
|
35
35
|
while current_token = next_token
|
36
36
|
yield current_token
|
@@ -43,7 +43,7 @@ module Pinpoint
|
|
43
43
|
# Returns a TokenList
|
44
44
|
#
|
45
45
|
def to_token_list
|
46
|
-
TokenList.new(
|
46
|
+
TokenList.new(to_a)
|
47
47
|
end
|
48
48
|
|
49
49
|
protected
|
@@ -93,7 +93,7 @@ module Pinpoint
|
|
93
93
|
left_paren: /%\(/,
|
94
94
|
right_paren: /%\)/,
|
95
95
|
group_start: /\(/,
|
96
|
-
group_end: /\)
|
96
|
+
group_end: /\)/,
|
97
97
|
}
|
98
98
|
end
|
99
99
|
|
@@ -151,20 +151,20 @@ module Pinpoint
|
|
151
151
|
return if tokenable.eos?
|
152
152
|
|
153
153
|
case
|
154
|
-
when text = tokenable.scan(token_map[:literal])
|
155
|
-
when text = tokenable.scan(token_map[:name])
|
156
|
-
when text = tokenable.scan(token_map[:street])
|
157
|
-
when text = tokenable.scan(token_map[:locality])
|
158
|
-
when text = tokenable.scan(token_map[:province])
|
159
|
-
when text = tokenable.scan(token_map[:postal_code])
|
160
|
-
when text = tokenable.scan(token_map[:country])
|
161
|
-
when text = tokenable.scan(token_map[:percent])
|
162
|
-
when text = tokenable.scan(token_map[:left_paren])
|
163
|
-
when text = tokenable.scan(token_map[:right_paren])
|
164
|
-
when text = tokenable.scan(token_map[:group_start])
|
165
|
-
when text = tokenable.scan(token_map[:group_end])
|
154
|
+
when text = tokenable.scan(token_map[:literal]) then Token.new(:literal, text)
|
155
|
+
when text = tokenable.scan(token_map[:name]) then Token.new(:name, text)
|
156
|
+
when text = tokenable.scan(token_map[:street]) then Token.new(:street, text)
|
157
|
+
when text = tokenable.scan(token_map[:locality]) then Token.new(:locality, text)
|
158
|
+
when text = tokenable.scan(token_map[:province]) then Token.new(:province, text)
|
159
|
+
when text = tokenable.scan(token_map[:postal_code]) then Token.new(:postal_code, text)
|
160
|
+
when text = tokenable.scan(token_map[:country]) then Token.new(:country, text)
|
161
|
+
when text = tokenable.scan(token_map[:percent]) then Token.new(:literal, '%')
|
162
|
+
when text = tokenable.scan(token_map[:left_paren]) then Token.new(:literal, '(')
|
163
|
+
when text = tokenable.scan(token_map[:right_paren]) then Token.new(:literal, ')')
|
164
|
+
when text = tokenable.scan(token_map[:group_start]) then Token.new(:group_start, text)
|
165
|
+
when text = tokenable.scan(token_map[:group_end]) then Token.new(:group_end, text)
|
166
166
|
else
|
167
|
-
|
167
|
+
fail ParseError, "Cannot parse the remainder of the tokenable string: '#{tokenable.rest}'"
|
168
168
|
end
|
169
169
|
end
|
170
170
|
end
|
data/lib/pinpoint/formatter.rb
CHANGED
@@ -2,7 +2,6 @@ require 'pinpoint/format/list'
|
|
2
2
|
|
3
3
|
module Pinpoint
|
4
4
|
class Formatter
|
5
|
-
|
6
5
|
##
|
7
6
|
# Public: Is able to process an Address into numerous formats based on the
|
8
7
|
# country and style, or a completely custom format.
|
@@ -74,7 +73,7 @@ module Pinpoint
|
|
74
73
|
|
75
74
|
format = formats[country]
|
76
75
|
|
77
|
-
format.output address, :
|
76
|
+
format.output address, style: style
|
78
77
|
end
|
79
78
|
|
80
79
|
private
|
data/lib/pinpoint/mapable.rb
CHANGED
@@ -5,7 +5,6 @@ require 'pinpoint/mapable_services/mapquest'
|
|
5
5
|
|
6
6
|
module Pinpoint
|
7
7
|
module Mapable
|
8
|
-
|
9
8
|
##
|
10
9
|
# Public: Creates a URL which can be used to locate the Mapable on a map
|
11
10
|
# using one of the supported services:
|
@@ -32,8 +31,8 @@ module Pinpoint
|
|
32
31
|
service = options.fetch(:via, :google_maps)
|
33
32
|
service_class = service_class_for(service)
|
34
33
|
|
35
|
-
service_class.map_url location:
|
36
|
-
location_name:
|
34
|
+
service_class.map_url location: to_s,
|
35
|
+
location_name: name
|
37
36
|
end
|
38
37
|
|
39
38
|
private
|
@@ -62,7 +62,7 @@ module Pinpoint
|
|
62
62
|
object.send(:define_method, field_name) do
|
63
63
|
address_fields_and_values = field_pairs.map do |field_pair|
|
64
64
|
[field_pair[0], send(field_pair[1])]
|
65
|
-
|
65
|
+
end
|
66
66
|
|
67
67
|
address_fields_and_values = Hash[address_fields_and_values]
|
68
68
|
|
@@ -136,12 +136,12 @@ module Pinpoint
|
|
136
136
|
gsub(/\A#{prefix}/, '').
|
137
137
|
gsub(/=\z/, '').
|
138
138
|
to_sym
|
139
|
-
|
139
|
+
end
|
140
140
|
|
141
141
|
{
|
142
142
|
base_fields: base_fields,
|
143
143
|
reader_fields: reader_fields,
|
144
|
-
writer_fields: writer_fields
|
144
|
+
writer_fields: writer_fields,
|
145
145
|
}
|
146
146
|
end
|
147
147
|
|
data/lib/pinpoint/version.rb
CHANGED
data/spec/address_spec.rb
CHANGED
@@ -1,48 +1,48 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'pinpoint/address'
|
3
3
|
|
4
4
|
describe 'Pinpoint::Address' do
|
5
5
|
let(:address) { Pinpoint::Address.new }
|
6
6
|
|
7
|
-
it { address.respond_to?(:region).
|
8
|
-
it { address.respond_to?(:region=).
|
9
|
-
it { address.respond_to?(:province).
|
10
|
-
it { address.respond_to?(:province=).
|
11
|
-
it { address.respond_to?(:locality).
|
12
|
-
it { address.respond_to?(:locality=).
|
13
|
-
it { address.respond_to?(:postal_code).
|
14
|
-
it { address.respond_to?(:postal_code=).
|
15
|
-
it { address.respond_to?(:zip).
|
16
|
-
it { address.respond_to?(:zip=).
|
17
|
-
it { address.respond_to?(:district).
|
18
|
-
it { address.respond_to?(:district=).
|
7
|
+
it { expect(address.respond_to?(:region)).to eql true }
|
8
|
+
it { expect(address.respond_to?(:region=)).to eql true }
|
9
|
+
it { expect(address.respond_to?(:province)).to eql true }
|
10
|
+
it { expect(address.respond_to?(:province=)).to eql true }
|
11
|
+
it { expect(address.respond_to?(:locality)).to eql true }
|
12
|
+
it { expect(address.respond_to?(:locality=)).to eql true }
|
13
|
+
it { expect(address.respond_to?(:postal_code)).to eql true }
|
14
|
+
it { expect(address.respond_to?(:postal_code=)).to eql true }
|
15
|
+
it { expect(address.respond_to?(:zip)).to eql true }
|
16
|
+
it { expect(address.respond_to?(:zip=)).to eql true }
|
17
|
+
it { expect(address.respond_to?(:district)).to eql true }
|
18
|
+
it { expect(address.respond_to?(:district=)).to eql true }
|
19
19
|
|
20
20
|
describe '#new' do
|
21
21
|
context 'when it is passed a set of initial values as a Hash' do
|
22
22
|
let(:address) do
|
23
23
|
Pinpoint::Address.new(
|
24
|
-
name:
|
25
|
-
street:
|
26
|
-
city:
|
27
|
-
state:
|
28
|
-
county:
|
29
|
-
zip_code:
|
30
|
-
country:
|
31
|
-
latitude:
|
32
|
-
longitude:
|
24
|
+
name: 'The Frist Center for the Visual Arts',
|
25
|
+
street: '919 Broadway',
|
26
|
+
city: 'Nashville',
|
27
|
+
state: 'Tennessee',
|
28
|
+
county: 'Davidson',
|
29
|
+
zip_code: '37203',
|
30
|
+
country: 'United States',
|
31
|
+
latitude: '36.15885623029150',
|
32
|
+
longitude: '-86.78226636970851',
|
33
33
|
)
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'sets its values properly' do
|
37
|
-
address.name.
|
38
|
-
address.street.
|
39
|
-
address.city.
|
40
|
-
address.state.
|
41
|
-
address.county.
|
42
|
-
address.zip_code.
|
43
|
-
address.country.
|
44
|
-
address.latitude.
|
45
|
-
address.longitude.
|
37
|
+
expect(address.name).to eql 'The Frist Center for the Visual Arts'
|
38
|
+
expect(address.street).to eql '919 Broadway'
|
39
|
+
expect(address.city).to eql 'Nashville'
|
40
|
+
expect(address.state).to eql 'Tennessee'
|
41
|
+
expect(address.county).to eql 'Davidson'
|
42
|
+
expect(address.zip_code).to eql '37203'
|
43
|
+
expect(address.country).to eql 'United States'
|
44
|
+
expect(address.latitude).to eql '36.15885623029150'
|
45
|
+
expect(address.longitude).to eql '-86.78226636970851'
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -51,64 +51,64 @@ describe 'Pinpoint::Address' do
|
|
51
51
|
context 'when any of the main parts of the address are blank' do
|
52
52
|
let(:address) do
|
53
53
|
Pinpoint::Address.new(
|
54
|
-
street:
|
55
|
-
city:
|
56
|
-
state:
|
57
|
-
zip_code:
|
58
|
-
country:
|
54
|
+
street: '',
|
55
|
+
city: 'Nashville',
|
56
|
+
state: 'Tennessee',
|
57
|
+
zip_code: '37203',
|
58
|
+
country: 'US',
|
59
59
|
)
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'is false' do
|
63
|
-
address.
|
63
|
+
expect(address).not_to be_complete
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
context 'when any of the main parts of the address are missing' do
|
68
68
|
let(:address) do
|
69
69
|
Pinpoint::Address.new(
|
70
|
-
street:
|
71
|
-
city:
|
72
|
-
state:
|
73
|
-
zip_code:
|
74
|
-
country:
|
70
|
+
street: nil,
|
71
|
+
city: 'Nashville',
|
72
|
+
state: 'Tennessee',
|
73
|
+
zip_code: '37203',
|
74
|
+
country: 'US',
|
75
75
|
)
|
76
76
|
end
|
77
77
|
|
78
78
|
it 'is false' do
|
79
|
-
address.
|
79
|
+
expect(address).not_to be_complete
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
83
|
context 'when all of the main parts of the address are present' do
|
84
84
|
let(:address) do
|
85
85
|
Pinpoint::Address.new(
|
86
|
-
street:
|
87
|
-
city:
|
88
|
-
state:
|
89
|
-
zip_code:
|
90
|
-
country:
|
86
|
+
street: '919 Broadway',
|
87
|
+
city: 'Nashville',
|
88
|
+
state: 'Tennessee',
|
89
|
+
zip_code: '37203',
|
90
|
+
country: 'US',
|
91
91
|
)
|
92
92
|
end
|
93
93
|
|
94
94
|
it 'is true' do
|
95
|
-
address.
|
95
|
+
expect(address).to be_complete
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
99
|
context 'when all of the main parts of the address are missing' do
|
100
100
|
let(:address) do
|
101
101
|
Pinpoint::Address.new(
|
102
|
-
street:
|
103
|
-
city:
|
104
|
-
state:
|
105
|
-
zip_code:
|
106
|
-
country:
|
102
|
+
street: nil,
|
103
|
+
city: nil,
|
104
|
+
state: nil,
|
105
|
+
zip_code: nil,
|
106
|
+
country: nil,
|
107
107
|
)
|
108
108
|
end
|
109
109
|
|
110
110
|
it 'is false' do
|
111
|
-
address.
|
111
|
+
expect(address).not_to be_complete
|
112
112
|
end
|
113
113
|
end
|
114
114
|
end
|
@@ -117,64 +117,64 @@ describe 'Pinpoint::Address' do
|
|
117
117
|
context 'when any of the main parts of the address are blank' do
|
118
118
|
let(:address) do
|
119
119
|
Pinpoint::Address.new(
|
120
|
-
street:
|
121
|
-
city:
|
122
|
-
state:
|
123
|
-
zip_code:
|
124
|
-
country:
|
120
|
+
street: '',
|
121
|
+
city: 'Nashville',
|
122
|
+
state: 'Tennessee',
|
123
|
+
zip_code: '37203',
|
124
|
+
country: 'US',
|
125
125
|
)
|
126
126
|
end
|
127
127
|
|
128
128
|
it 'is true' do
|
129
|
-
address.
|
129
|
+
expect(address).to be_incomplete
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
133
|
context 'when any of the main parts of the address are missing' do
|
134
134
|
let(:address) do
|
135
135
|
Pinpoint::Address.new(
|
136
|
-
street:
|
137
|
-
city:
|
138
|
-
state:
|
139
|
-
zip_code:
|
140
|
-
country:
|
136
|
+
street: nil,
|
137
|
+
city: 'Nashville',
|
138
|
+
state: 'Tennessee',
|
139
|
+
zip_code: '37203',
|
140
|
+
country: 'US',
|
141
141
|
)
|
142
142
|
end
|
143
143
|
|
144
144
|
it 'is true' do
|
145
|
-
address.
|
145
|
+
expect(address).to be_incomplete
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
149
|
context 'when all of the main parts of the address are present' do
|
150
150
|
let(:address) do
|
151
151
|
Pinpoint::Address.new(
|
152
|
-
street:
|
153
|
-
city:
|
154
|
-
state:
|
155
|
-
zip_code:
|
156
|
-
country:
|
152
|
+
street: '919 Broadway',
|
153
|
+
city: 'Nashville',
|
154
|
+
state: 'Tennessee',
|
155
|
+
zip_code: '37203',
|
156
|
+
country: 'US',
|
157
157
|
)
|
158
158
|
end
|
159
159
|
|
160
160
|
it 'is false' do
|
161
|
-
address.
|
161
|
+
expect(address).not_to be_incomplete
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
165
165
|
context 'when all of the main parts of the address are missing' do
|
166
166
|
let(:address) do
|
167
167
|
Pinpoint::Address.new(
|
168
|
-
street:
|
169
|
-
city:
|
170
|
-
state:
|
171
|
-
zip_code:
|
172
|
-
country:
|
168
|
+
street: nil,
|
169
|
+
city: nil,
|
170
|
+
state: nil,
|
171
|
+
zip_code: nil,
|
172
|
+
country: nil,
|
173
173
|
)
|
174
174
|
end
|
175
175
|
|
176
176
|
it 'is false' do
|
177
|
-
address.
|
177
|
+
expect(address).not_to be_incomplete
|
178
178
|
end
|
179
179
|
end
|
180
180
|
end
|
@@ -183,64 +183,64 @@ describe 'Pinpoint::Address' do
|
|
183
183
|
context 'when any of the main parts of the address are blank' do
|
184
184
|
let(:address) do
|
185
185
|
Pinpoint::Address.new(
|
186
|
-
street:
|
187
|
-
city:
|
188
|
-
state:
|
189
|
-
zip_code:
|
190
|
-
country:
|
186
|
+
street: '',
|
187
|
+
city: 'Nashville',
|
188
|
+
state: 'Tennessee',
|
189
|
+
zip_code: '37203',
|
190
|
+
country: 'US',
|
191
191
|
)
|
192
192
|
end
|
193
193
|
|
194
194
|
it 'is false' do
|
195
|
-
address.
|
195
|
+
expect(address).not_to be_empty
|
196
196
|
end
|
197
197
|
end
|
198
198
|
|
199
199
|
context 'when any of the main parts of the address are missing' do
|
200
200
|
let(:address) do
|
201
201
|
Pinpoint::Address.new(
|
202
|
-
street:
|
203
|
-
city:
|
204
|
-
state:
|
205
|
-
zip_code:
|
206
|
-
country:
|
202
|
+
street: nil,
|
203
|
+
city: 'Nashville',
|
204
|
+
state: 'Tennessee',
|
205
|
+
zip_code: '37203',
|
206
|
+
country: 'US',
|
207
207
|
)
|
208
208
|
end
|
209
209
|
|
210
210
|
it 'is false' do
|
211
|
-
address.
|
211
|
+
expect(address).not_to be_empty
|
212
212
|
end
|
213
213
|
end
|
214
214
|
|
215
215
|
context 'when all of the main parts of the address are present' do
|
216
216
|
let(:address) do
|
217
217
|
Pinpoint::Address.new(
|
218
|
-
street:
|
219
|
-
city:
|
220
|
-
state:
|
221
|
-
zip_code:
|
222
|
-
country:
|
218
|
+
street: '919 Broadway',
|
219
|
+
city: 'Nashville',
|
220
|
+
state: 'Tennessee',
|
221
|
+
zip_code: '37203',
|
222
|
+
country: 'US',
|
223
223
|
)
|
224
224
|
end
|
225
225
|
|
226
226
|
it 'is false' do
|
227
|
-
address.
|
227
|
+
expect(address).not_to be_empty
|
228
228
|
end
|
229
229
|
end
|
230
230
|
|
231
231
|
context 'when all of the main parts of the address are missing' do
|
232
232
|
let(:address) do
|
233
233
|
Pinpoint::Address.new(
|
234
|
-
street:
|
235
|
-
city:
|
236
|
-
state:
|
237
|
-
zip_code:
|
238
|
-
country:
|
234
|
+
street: nil,
|
235
|
+
city: nil,
|
236
|
+
state: nil,
|
237
|
+
zip_code: nil,
|
238
|
+
country: nil,
|
239
239
|
)
|
240
240
|
end
|
241
241
|
|
242
242
|
it 'is true' do
|
243
|
-
address.
|
243
|
+
expect(address).to be_empty
|
244
244
|
end
|
245
245
|
end
|
246
246
|
end
|