diff --git a/lib/geocoder/lookups/ipdata_co.rb b/lib/geocoder/lookups/ipdata_co.rb index f1322a2c8cfd995b9d51e4c8ca6c964efb268c55..a5fa295c17684ecc0c5cdbd847a33ea947accc2b 100644 --- a/lib/geocoder/lookups/ipdata_co.rb +++ b/lib/geocoder/lookups/ipdata_co.rb @@ -18,10 +18,6 @@ module Geocoder::Lookup private # --------------------------------------------------------------- - def parse_raw_data(raw_data) - raw_data.match(/^<html><title>404/) ? nil : super(raw_data) - end - def results(query) # don't look up a loopback address, just return the stored result return [reserved_result(query.text)] if query.loopback_ip_address? diff --git a/test/fixtures/ipdata_co_8_8_8 b/test/fixtures/ipdata_co_8_8_8 new file mode 100644 index 0000000000000000000000000000000000000000..2462e1270a88da040f6f434f9f52faf215522c5f --- /dev/null +++ b/test/fixtures/ipdata_co_8_8_8 @@ -0,0 +1 @@ +8.8.8 does not appear to be an IPv4 or IPv6 address \ No newline at end of file diff --git a/test/unit/lookups/ipdata_co_test.rb b/test/unit/lookups/ipdata_co_test.rb index fcd98f80bebecdc7b2e6f48085c41210cfcca6fa..3811a13c1a40771e961dab59139510ff0f8b1c06 100644 --- a/test/unit/lookups/ipdata_co_test.rb +++ b/test/unit/lookups/ipdata_co_test.rb @@ -12,8 +12,16 @@ class IpdataCoTest < GeocoderTestCase assert result.is_a?(Geocoder::Result::IpdataCo) 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 result = Geocoder.search("74.200.247.59").first assert_equal "Jersey City, NJ 07302, United States", result.address end + end