Skip to content
Snippets Groups Projects
Unverified Commit 3cfd2a20 authored by Robert Schaefer's avatar Robert Schaefer
Browse files

Proper error handling

Remove silly check for HTML tags
Add test case for invalid json
parent 9e374887
No related branches found
No related tags found
No related merge requests found
...@@ -18,10 +18,6 @@ module Geocoder::Lookup ...@@ -18,10 +18,6 @@ module Geocoder::Lookup
private # --------------------------------------------------------------- private # ---------------------------------------------------------------
def parse_raw_data(raw_data)
raw_data.match(/^<html><title>404/) ? nil : super(raw_data)
end
def results(query) def results(query)
# don't look up a loopback address, just return the stored result # don't look up a loopback address, just return the stored result
return [reserved_result(query.text)] if query.loopback_ip_address? return [reserved_result(query.text)] if query.loopback_ip_address?
......
8.8.8 does not appear to be an IPv4 or IPv6 address
\ No newline at end of file
...@@ -12,8 +12,16 @@ class IpdataCoTest < GeocoderTestCase ...@@ -12,8 +12,16 @@ class IpdataCoTest < GeocoderTestCase
assert result.is_a?(Geocoder::Result::IpdataCo) assert result.is_a?(Geocoder::Result::IpdataCo)
end end
def test_invalid_json
Geocoder.configure(:always_raise => [Geocoder::ResponseParseError])
assert_raise Geocoder::ResponseParseError do
Geocoder.search("8.8.8", ip_address: true)
end
end
def test_result_components def test_result_components
result = Geocoder.search("74.200.247.59").first result = Geocoder.search("74.200.247.59").first
assert_equal "Jersey City, NJ 07302, United States", result.address assert_equal "Jersey City, NJ 07302, United States", result.address
end end
end end
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