Sha256: 3e9d5232e8cca647386c9cc8811c0328bfb5a722822b3b8386598c03398e5d48

Contents?: true

Size: 1.15 KB

Versions: 5

Compression:

Stored size: 1.15 KB

Contents

# encoding: utf-8
require 'test_helper'

class ErrorHandlingTest < Test::Unit::TestCase

  def teardown
    Geocoder.configure(:always_raise => [])
  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") }
    end
  ensure
    $VERBOSE = orig
  end

  def test_always_raise_timeout_error
    Geocoder.configure(:always_raise => [TimeoutError])
    Geocoder::Lookup.all_services_except_test.each do |l|
      lookup = Geocoder::Lookup.get(l)
      set_api_key!(l)
      assert_raises TimeoutError do
        lookup.send(:results, Geocoder::Query.new("timeout"))
      end
    end
  end

  def test_always_raise_socket_error
    Geocoder.configure(:always_raise => [SocketError])
    Geocoder::Lookup.all_services_except_test.each do |l|
      lookup = Geocoder::Lookup.get(l)
      set_api_key!(l)
      assert_raises SocketError do
        lookup.send(:results, Geocoder::Query.new("socket_error"))
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
geocoder-1.1.9 test/error_handling_test.rb
geocoder-1.1.8 test/error_handling_test.rb
geocoder-1.1.7 test/error_handling_test.rb
geocoder-sgonyea-1.1.6.1 test/error_handling_test.rb
geocoder-1.1.6 test/error_handling_test.rb