Skip to content

Commit

Permalink
Merge 8c215ed into 048a8d3
Browse files Browse the repository at this point in the history
  • Loading branch information
griffithchaffee committed Apr 5, 2019
2 parents 048a8d3 + 8c215ed commit 3e95f5b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/geocodio/address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ class Address
# How accurate geocod.io deemed this result to be given the original query.
#
# @return [Float] a number between 0 and 1
attr_reader :accuracy
attr_reader :accuracy, :accuracy_type

def initialize(payload = {})
set_attributes(payload['address_components']) if payload['address_components']
set_coordinates(payload['location']) if payload['location']
set_additional_fields(payload['fields']) if payload['fields']

@accuracy = payload['accuracy']
@accuracy_type = payload['accuracy_type']
@formatted_address = payload['formatted_address']
end

Expand Down
12 changes: 12 additions & 0 deletions spec/address_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
it 'does not have an accuracy' do
expect(address.accuracy).to be_nil
end

it 'does not have an accuracy_type' do
expect(address.accuracy_type).to be_nil
end
end

context 'when geocoded' do
Expand Down Expand Up @@ -114,6 +118,10 @@
it 'has an accuracy' do
expect(address.accuracy).to eq(1)
end

it 'has an accuracy_type' do
expect(address.accuracy_type).to eq("rooftop")
end
end

context 'has postdirectional' do
Expand Down Expand Up @@ -172,6 +180,10 @@
it 'has an accuracy' do
expect(address.accuracy).to eq(1)
end

it 'has an accuracy_type' do
expect(address.accuracy_type).to eq("rooftop")
end
end

context 'with additional fields' do
Expand Down

0 comments on commit 3e95f5b

Please sign in to comment.