From 835b14c1c1f6084267f0de82d3d25c57c2440166 Mon Sep 17 00:00:00 2001
From: Alex Reisner <alex@alexreisner.com>
Date: Sat, 1 Mar 2014 18:15:25 -0500
Subject: [PATCH] Use ActiveSupport's silence_warnings method.

---
 test/unit/error_handling_test.rb | 14 ++++++--------
 test/unit/lookup_test.rb         | 16 +++++++---------
 test/unit/lookups/yahoo_test.rb  |  8 +++-----
 3 files changed, 16 insertions(+), 22 deletions(-)

diff --git a/test/unit/error_handling_test.rb b/test/unit/error_handling_test.rb
index 58dc37f8..e999af94 100644
--- a/test/unit/error_handling_test.rb
+++ b/test/unit/error_handling_test.rb
@@ -9,15 +9,13 @@ class ErrorHandlingTest < GeocoderTestCase
   end
 
   def test_does_not_choke_on_timeout
-    # keep test output clean: suppress timeout warning
-    orig = $VERBOSE; $VERBOSE = nil
-    Geocoder::Lookup.all_services_except_test.each do |l|
-      Geocoder.configure(:lookup => l)
-      set_api_key!(l)
-      assert_nothing_raised { Geocoder.search("timeout") }
+    silence_warnings do
+      Geocoder::Lookup.all_services_except_test.each do |l|
+        Geocoder.configure(:lookup => l)
+        set_api_key!(l)
+        assert_nothing_raised { Geocoder.search("timeout") }
+      end
     end
-  ensure
-    $VERBOSE = orig
   end
 
   def test_always_raise_timeout_error
diff --git a/test/unit/lookup_test.rb b/test/unit/lookup_test.rb
index c4bc3649..83561537 100644
--- a/test/unit/lookup_test.rb
+++ b/test/unit/lookup_test.rb
@@ -68,16 +68,14 @@ class LookupTest < GeocoderTestCase
   end
 
   def test_returns_empty_array_on_invalid_key
-    # keep test output clean: suppress timeout warning
-    orig = $VERBOSE; $VERBOSE = nil
-    #Geocoder::Lookup.all_services_except_test.each do |l|
-    [:bing, :yahoo, :yandex, :maxmind, :cloudmade, :baidu, :baidu_ip].each do |l|
-      Geocoder.configure(:lookup => l)
-      set_api_key!(l)
-      assert_equal [], Geocoder.search("invalid key")
+    silence_warnings do
+      #Geocoder::Lookup.all_services_except_test.each do |l|
+      [:bing, :yahoo, :yandex, :maxmind, :cloudmade, :baidu, :baidu_ip].each do |l|
+        Geocoder.configure(:lookup => l)
+        set_api_key!(l)
+        assert_equal [], Geocoder.search("invalid key")
+      end
     end
-  ensure
-    $VERBOSE = orig
   end
 
   def test_does_not_choke_on_nil_address
diff --git a/test/unit/lookups/yahoo_test.rb b/test/unit/lookups/yahoo_test.rb
index 3bdef12d..b576dd72 100644
--- a/test/unit/lookups/yahoo_test.rb
+++ b/test/unit/lookups/yahoo_test.rb
@@ -14,11 +14,9 @@ class YahooTest < GeocoderTestCase
   end
 
   def test_error
-    # keep test output clean: suppress timeout warning
-    orig = $VERBOSE; $VERBOSE = nil
-    assert_equal [], Geocoder.search("error")
-  ensure
-    $VERBOSE = orig
+    silence_warnings do
+      assert_equal [], Geocoder.search("error")
+    end
   end
 
   def test_result_components
-- 
GitLab