test/google_lookup_test.rb in timezone-0.3.9 vs test/google_lookup_test.rb in timezone-0.3.10

- old
+ new

@@ -1,14 +1,13 @@ require 'timezone/configure' require 'timezone/lookup/google' -require 'test/unit' +require 'minitest/autorun' require_relative 'http_test_client' -class GoogleLookupTest < ::Test::Unit::TestCase +class GoogleLookupTest < ::Minitest::Unit::TestCase def setup Timezone::Configure.begin do |c| - c.google_api_key = nil c.http_client = HTTPTestClient c.google_api_key = '123abc' end end @@ -18,17 +17,25 @@ def lookup ::Timezone::Lookup::Google.new(Timezone::Configure) end + def test_missing_api_key + Timezone::Configure.begin{ |c| c.google_api_key = nil } + assert_raises(::Timezone::Error::InvalidConfig){ lookup } + ensure + Timezone::Configure.begin{ |c| c.google_api_key = '123abc' } + end + def test_google_using_lat_lon_coordinates HTTPTestClient.body = File.open(mock_path + '/google_lat_lon_coords.txt').read assert_equal 'Australia/Adelaide', lookup.lookup(*coordinates) end def test_google_request_denied_read_lat_lon_coordinates - assert_raise Timezone::Error::Google, 'The provided API key is invalid.' do + HTTPTestClient.body = nil + assert_raises Timezone::Error::Google, 'The provided API key is invalid.' do lookup.lookup(*coordinates) end end private