Skip to content
Snippets Groups Projects
Commit 963ba724 authored by Rob Murray's avatar Rob Murray
Browse files

It appears that we have to implement the 'city' method on the 'Results' object too

parent 8d7e72f4
No related branches found
No related tags found
No related merge requests found
...@@ -14,6 +14,17 @@ module Geocoder::Result ...@@ -14,6 +14,17 @@ module Geocoder::Result
alias_method :state_code, :blank_result alias_method :state_code, :blank_result
alias_method :postal_code, :blank_result alias_method :postal_code, :blank_result
def address
[@data['Location'], @data['OsGrid']].join(', ')
end
def city
# is this too big a jump to assume that the API always
# returns a City, County as the last elements?
city = @data['Location'].split(',')[-2]
city.strip
end
def country def country
'United Kingdom' 'United Kingdom'
end end
...@@ -21,9 +32,5 @@ module Geocoder::Result ...@@ -21,9 +32,5 @@ module Geocoder::Result
def country_code def country_code
'UK' 'UK'
end end
def address
[@data['Location'], @data['OsGrid']].join(', ')
end
end end
end end
\ No newline at end of file
...@@ -13,18 +13,18 @@ class PostcodeAnywhereUkTest < GeocoderTestCase ...@@ -13,18 +13,18 @@ class PostcodeAnywhereUkTest < GeocoderTestCase
results = Geocoder.search('Madison Square Garden') results = Geocoder.search('Madison Square Garden')
assert_equal 1, results.size assert_equal 1, results.size
result = results.first assert_equal 'Maidstone, Kent, TQ 76153 55386', results.first.address
assert_equal 'Maidstone, Kent, TQ 76153 55386', result.address assert_equal [51.2703, 0.5238], results.first.coordinates
assert_equal [51.2703, 0.5238], result.coordinates assert_equal 'Maidstone', results.first.city
end end
def test_WR26NJ def test_WR26NJ
results = Geocoder.search('WR26NJ') results = Geocoder.search('WR26NJ')
assert_equal 1, results.size assert_equal 1, results.size
result = results.first assert_equal 'Moseley Road, Hallow, Worcester, SO 81676 59425', results.first.address
assert_equal 'Moseley Road, Hallow, Worcester, SO 81676 59425', result.address assert_equal [52.2327, -2.2697], results.first.coordinates
assert_equal [52.2327, -2.2697], result.coordinates assert_equal 'Hallow', results.first.city
end end
def test_no_results def test_no_results
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment