From 0278154cf05b6f6c2b5f537019370c8a303015d5 Mon Sep 17 00:00:00 2001
From: Alex Reisner <alex@alexreisner.com>
Date: Mon, 24 Feb 2014 12:26:43 -0500
Subject: [PATCH] Use subclass instead of overriding methods directly.
---
test/test_helper.rb | 4 +++-
test/unit/active_record_test.rb | 2 +-
test/unit/cache_test.rb | 2 +-
test/unit/calculations_test.rb | 2 +-
test/unit/configuration_test.rb | 2 +-
test/unit/error_handling_test.rb | 2 +-
test/unit/geocoder_test.rb | 2 +-
test/unit/https_test.rb | 2 +-
test/unit/ip_address_test.rb | 2 +-
test/unit/lookup_test.rb | 2 +-
test/unit/lookups/bing_test.rb | 2 +-
test/unit/lookups/dstk_test.rb | 2 +-
test/unit/lookups/esri_test.rb | 2 +-
test/unit/lookups/freegeoip_test.rb | 2 +-
test/unit/lookups/geocoder_ca_test.rb | 2 +-
test/unit/lookups/geocodio_test.rb | 2 +-
test/unit/lookups/google_premier_test.rb | 2 +-
test/unit/lookups/google_test.rb | 2 +-
test/unit/lookups/mapquest_test.rb | 2 +-
test/unit/lookups/maxmind_local_test.rb | 2 +-
test/unit/lookups/maxmind_test.rb | 2 +-
test/unit/lookups/nominatim_test.rb | 2 +-
test/unit/lookups/yahoo_test.rb | 2 +-
test/unit/method_aliases_test.rb | 2 +-
test/unit/model_test.rb | 2 +-
test/unit/mongoid_test.rb | 2 +-
test/unit/near_test.rb | 2 +-
test/unit/oauth_util_test.rb | 2 +-
test/unit/proxy_test.rb | 2 +-
test/unit/query_test.rb | 2 +-
test/unit/request_test.rb | 2 +-
test/unit/result_test.rb | 2 +-
test/unit/test_mode_test.rb | 2 +-
33 files changed, 35 insertions(+), 33 deletions(-)
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 20d3a13d..9235be2f 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -310,15 +310,17 @@ class PlaceReverseGeocodedWithCustomLookup < ActiveRecord::Base
end
-class Test::Unit::TestCase
+class GeocoderTestCase < Test::Unit::TestCase
def setup
+ super
Geocoder.configure(:maxmind => {:service => :city_isp_org})
end
def teardown
Geocoder.send(:remove_const, :Configuration)
load "geocoder/configuration.rb"
+ super
end
def geocoded_object_params(abbrev)
diff --git a/test/unit/active_record_test.rb b/test/unit/active_record_test.rb
index fff9896a..33927653 100644
--- a/test/unit/active_record_test.rb
+++ b/test/unit/active_record_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class ActiveRecordTest < Test::Unit::TestCase
+class ActiveRecordTest < GeocoderTestCase
def test_exclude_condition_when_model_has_a_custom_primary_key
venue = PlaceWithCustomPrimaryKey.new(*geocoded_object_params(:msg))
diff --git a/test/unit/cache_test.rb b/test/unit/cache_test.rb
index ecd8a2c5..d4730964 100644
--- a/test/unit/cache_test.rb
+++ b/test/unit/cache_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class CacheTest < Test::Unit::TestCase
+class CacheTest < GeocoderTestCase
def test_second_occurrence_of_request_is_cache_hit
Geocoder.configure(:cache => {})
diff --git a/test/unit/calculations_test.rb b/test/unit/calculations_test.rb
index 272eca1f..98fdfbcd 100644
--- a/test/unit/calculations_test.rb
+++ b/test/unit/calculations_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class CalculationsTest < Test::Unit::TestCase
+class CalculationsTest < GeocoderTestCase
def setup
Geocoder.configure(
:units => :mi,
diff --git a/test/unit/configuration_test.rb b/test/unit/configuration_test.rb
index 8b9575a3..527a57e7 100644
--- a/test/unit/configuration_test.rb
+++ b/test/unit/configuration_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class ConfigurationTest < Test::Unit::TestCase
+class ConfigurationTest < GeocoderTestCase
def setup
Geocoder::Configuration.set_defaults
end
diff --git a/test/unit/error_handling_test.rb b/test/unit/error_handling_test.rb
index cd83c3cd..faf53192 100644
--- a/test/unit/error_handling_test.rb
+++ b/test/unit/error_handling_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class ErrorHandlingTest < Test::Unit::TestCase
+class ErrorHandlingTest < GeocoderTestCase
def teardown
Geocoder.configure(:always_raise => [])
diff --git a/test/unit/geocoder_test.rb b/test/unit/geocoder_test.rb
index 220991d3..7dc4e0f5 100644
--- a/test/unit/geocoder_test.rb
+++ b/test/unit/geocoder_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class GeocoderTest < Test::Unit::TestCase
+class GeocoderTest < GeocoderTestCase
def test_distance_to_returns_float
v = Place.new(*geocoded_object_params(:msg))
diff --git a/test/unit/https_test.rb b/test/unit/https_test.rb
index dd6d0204..14420dfc 100644
--- a/test/unit/https_test.rb
+++ b/test/unit/https_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class HttpsTest < Test::Unit::TestCase
+class HttpsTest < GeocoderTestCase
def test_uses_https_for_secure_query
Geocoder.configure(:use_https => true)
diff --git a/test/unit/ip_address_test.rb b/test/unit/ip_address_test.rb
index fcdcd809..2e36f8bb 100644
--- a/test/unit/ip_address_test.rb
+++ b/test/unit/ip_address_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class IpAddressTest < Test::Unit::TestCase
+class IpAddressTest < GeocoderTestCase
def test_valid
assert Geocoder::IpAddress.new("232.65.123.94").valid?
diff --git a/test/unit/lookup_test.rb b/test/unit/lookup_test.rb
index cd8c412e..0f8dae4b 100644
--- a/test/unit/lookup_test.rb
+++ b/test/unit/lookup_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class LookupTest < Test::Unit::TestCase
+class LookupTest < GeocoderTestCase
def test_responds_to_name_method
Geocoder::Lookup.all_services.each do |l|
diff --git a/test/unit/lookups/bing_test.rb b/test/unit/lookups/bing_test.rb
index 7e886ae8..f55e2ef9 100644
--- a/test/unit/lookups/bing_test.rb
+++ b/test/unit/lookups/bing_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class BingTest < Test::Unit::TestCase
+class BingTest < GeocoderTestCase
def setup
Geocoder.configure(lookup: :bing)
diff --git a/test/unit/lookups/dstk_test.rb b/test/unit/lookups/dstk_test.rb
index e05cf32b..2e73e447 100644
--- a/test/unit/lookups/dstk_test.rb
+++ b/test/unit/lookups/dstk_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class DstkTest < Test::Unit::TestCase
+class DstkTest < GeocoderTestCase
def setup
Geocoder.configure(lookup: :dstk)
diff --git a/test/unit/lookups/esri_test.rb b/test/unit/lookups/esri_test.rb
index da92592e..8d6bcbe1 100644
--- a/test/unit/lookups/esri_test.rb
+++ b/test/unit/lookups/esri_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class EsriTest < Test::Unit::TestCase
+class EsriTest < GeocoderTestCase
def setup
Geocoder.configure(lookup: :esri)
diff --git a/test/unit/lookups/freegeoip_test.rb b/test/unit/lookups/freegeoip_test.rb
index e0f31acb..565efb6b 100644
--- a/test/unit/lookups/freegeoip_test.rb
+++ b/test/unit/lookups/freegeoip_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class FreegeoipTest < Test::Unit::TestCase
+class FreegeoipTest < GeocoderTestCase
def setup
Geocoder.configure(ip_lookup: :freegeoip)
diff --git a/test/unit/lookups/geocoder_ca_test.rb b/test/unit/lookups/geocoder_ca_test.rb
index d9dffe20..927faaf0 100644
--- a/test/unit/lookups/geocoder_ca_test.rb
+++ b/test/unit/lookups/geocoder_ca_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class GeocoderCaTest < Test::Unit::TestCase
+class GeocoderCaTest < GeocoderTestCase
def setup
Geocoder.configure(lookup: :geocoder_ca)
diff --git a/test/unit/lookups/geocodio_test.rb b/test/unit/lookups/geocodio_test.rb
index 2237f5ea..bbf370a9 100644
--- a/test/unit/lookups/geocodio_test.rb
+++ b/test/unit/lookups/geocodio_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class GeocodioTest < Test::Unit::TestCase
+class GeocodioTest < GeocoderTestCase
def setup
Geocoder.configure(lookup: :geocodio)
diff --git a/test/unit/lookups/google_premier_test.rb b/test/unit/lookups/google_premier_test.rb
index b46b3f32..c96c4a1f 100644
--- a/test/unit/lookups/google_premier_test.rb
+++ b/test/unit/lookups/google_premier_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class GooglePremierTest < Test::Unit::TestCase
+class GooglePremierTest < GeocoderTestCase
def setup
Geocoder.configure(lookup: :google_premier)
diff --git a/test/unit/lookups/google_test.rb b/test/unit/lookups/google_test.rb
index 967f7d04..fec7acb3 100644
--- a/test/unit/lookups/google_test.rb
+++ b/test/unit/lookups/google_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class GoogleTest < Test::Unit::TestCase
+class GoogleTest < GeocoderTestCase
def test_google_result_components
result = Geocoder.search("Madison Square Garden, New York, NY").first
diff --git a/test/unit/lookups/mapquest_test.rb b/test/unit/lookups/mapquest_test.rb
index c77cbe7f..07e4bbb6 100644
--- a/test/unit/lookups/mapquest_test.rb
+++ b/test/unit/lookups/mapquest_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class MapquestTest < Test::Unit::TestCase
+class MapquestTest < GeocoderTestCase
def setup
Geocoder.configure(lookup: :mapquest)
diff --git a/test/unit/lookups/maxmind_local_test.rb b/test/unit/lookups/maxmind_local_test.rb
index b7de9a94..28ca4020 100644
--- a/test/unit/lookups/maxmind_local_test.rb
+++ b/test/unit/lookups/maxmind_local_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class MaxmindLocalTest < Test::Unit::TestCase
+class MaxmindLocalTest < GeocoderTestCase
def setup
Geocoder.configure(ip_lookup: :maxmind_local)
diff --git a/test/unit/lookups/maxmind_test.rb b/test/unit/lookups/maxmind_test.rb
index 41386bcd..6fc6cb02 100644
--- a/test/unit/lookups/maxmind_test.rb
+++ b/test/unit/lookups/maxmind_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class MaxmindTest < Test::Unit::TestCase
+class MaxmindTest < GeocoderTestCase
def setup
Geocoder.configure(ip_lookup: :maxmind)
diff --git a/test/unit/lookups/nominatim_test.rb b/test/unit/lookups/nominatim_test.rb
index ddab3d1f..310fa381 100644
--- a/test/unit/lookups/nominatim_test.rb
+++ b/test/unit/lookups/nominatim_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class NominatimTest < Test::Unit::TestCase
+class NominatimTest < GeocoderTestCase
def setup
Geocoder.configure(lookup: :nominatim)
diff --git a/test/unit/lookups/yahoo_test.rb b/test/unit/lookups/yahoo_test.rb
index 579f5b85..f299b7b7 100644
--- a/test/unit/lookups/yahoo_test.rb
+++ b/test/unit/lookups/yahoo_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class YahooTest < Test::Unit::TestCase
+class YahooTest < GeocoderTestCase
def setup
Geocoder.configure(lookup: :yahoo)
diff --git a/test/unit/method_aliases_test.rb b/test/unit/method_aliases_test.rb
index bb84c0b6..d33afc48 100644
--- a/test/unit/method_aliases_test.rb
+++ b/test/unit/method_aliases_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class MethodAliasesTest < Test::Unit::TestCase
+class MethodAliasesTest < GeocoderTestCase
def test_distance_from_is_alias_for_distance_to
v = Place.new(*geocoded_object_params(:msg))
diff --git a/test/unit/model_test.rb b/test/unit/model_test.rb
index f539eb04..a4f5d9f7 100644
--- a/test/unit/model_test.rb
+++ b/test/unit/model_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class ModelTest < Test::Unit::TestCase
+class ModelTest < GeocoderTestCase
def test_geocode_with_block_runs_block
e = PlaceWithCustomResultsHandling.new(*geocoded_object_params(:msg))
diff --git a/test/unit/mongoid_test.rb b/test/unit/mongoid_test.rb
index d050f4f8..78fd4a04 100644
--- a/test/unit/mongoid_test.rb
+++ b/test/unit/mongoid_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'mongoid_test_helper'
-class MongoidTest < Test::Unit::TestCase
+class MongoidTest < GeocoderTestCase
def test_geocoded_check
p = PlaceUsingMongoid.new(*geocoded_object_params(:msg))
p.location = [40.750354, -73.993371]
diff --git a/test/unit/near_test.rb b/test/unit/near_test.rb
index e62e46da..09083869 100644
--- a/test/unit/near_test.rb
+++ b/test/unit/near_test.rb
@@ -1,6 +1,6 @@
require 'test_helper'
-class NearTest < Test::Unit::TestCase
+class NearTest < GeocoderTestCase
def test_near_scope_options_without_sqlite_includes_bounding_box_condition
result = PlaceWithCustomResultsHandling.send(:near_scope_options, 1.0, 2.0, 5)
diff --git a/test/unit/oauth_util_test.rb b/test/unit/oauth_util_test.rb
index f9d1b534..d70e333f 100644
--- a/test/unit/oauth_util_test.rb
+++ b/test/unit/oauth_util_test.rb
@@ -3,7 +3,7 @@ require 'test_helper'
require 'cgi'
require 'uri'
-class OauthUtilTest < Test::Unit::TestCase
+class OauthUtilTest < GeocoderTestCase
def test_query_string_escapes_single_quote
base_url = "http://example.com?location=d'iberville"
diff --git a/test/unit/proxy_test.rb b/test/unit/proxy_test.rb
index 8460ee49..23d8789a 100644
--- a/test/unit/proxy_test.rb
+++ b/test/unit/proxy_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class ProxyTest < Test::Unit::TestCase
+class ProxyTest < GeocoderTestCase
def test_uses_proxy_when_specified
Geocoder.configure(:http_proxy => 'localhost')
diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb
index 58772d41..77c9839e 100644
--- a/test/unit/query_test.rb
+++ b/test/unit/query_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class QueryTest < Test::Unit::TestCase
+class QueryTest < GeocoderTestCase
def test_ip_address_detection
assert Geocoder::Query.new("232.65.123.94").ip_address?
diff --git a/test/unit/request_test.rb b/test/unit/request_test.rb
index 046bca2a..6ffe6b7d 100644
--- a/test/unit/request_test.rb
+++ b/test/unit/request_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class RequestTest < Test::Unit::TestCase
+class RequestTest < GeocoderTestCase
class MockRequest
include Geocoder::Request
attr_accessor :env, :ip
diff --git a/test/unit/result_test.rb b/test/unit/result_test.rb
index 4707b62a..631f3e7b 100644
--- a/test/unit/result_test.rb
+++ b/test/unit/result_test.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require 'test_helper'
-class ResultTest < Test::Unit::TestCase
+class ResultTest < GeocoderTestCase
def test_result_has_required_attributes
Geocoder::Lookup.all_services_except_test.each do |l|
diff --git a/test/unit/test_mode_test.rb b/test/unit/test_mode_test.rb
index 62911c55..df0c5480 100644
--- a/test/unit/test_mode_test.rb
+++ b/test/unit/test_mode_test.rb
@@ -1,6 +1,6 @@
require 'test_helper'
-class TestModeTest < Test::Unit::TestCase
+class TestModeTest < GeocoderTestCase
def setup
@_original_lookup = Geocoder.config.lookup
--
GitLab