Sha256: 2432faae5aa7922e94a72c7fe71461694e9e8a545ec07ec5e2cb83172e418e30
Contents?: true
Size: 1.37 KB
Versions: 3
Compression:
Stored size: 1.37 KB
Contents
require 'timezone/configure' require 'timezone/lookup/geonames' require 'minitest/autorun' require_relative 'http_test_client' class GeonamesLookupTest < ::Minitest::Unit::TestCase def setup Timezone::Configure.begin do |c| c.google_api_key = nil c.http_client = HTTPTestClient c.username = 'timezone' end end def coordinates [-34.92771808058, 138.477041423321] end def lookup ::Timezone::Configure.lookup end def clear Timezone::Configure.instance_variable_set(:@lookup, nil) Timezone::Configure.instance_variable_set(:@google_lookup, nil) Timezone::Configure.instance_variable_set(:@geonames_lookup, nil) end def test_missing_username clear Timezone::Configure.begin { |c| c.username = nil } assert_raises(::Timezone::Error::InvalidConfig) { lookup } ensure Timezone::Configure.begin { |c| c.username = 'timezone' } end def test_lookup lookup.client.body = File.open(mock_path + '/lat_lon_coords.txt').read assert_equal 'Australia/Adelaide', lookup.lookup(*coordinates) end def test_api_limit lookup.client.body = File.open(mock_path + '/api_limit_reached.txt').read assert_raises Timezone::Error::GeoNames, 'api limit reached' do lookup.lookup(*coordinates) end end private def mock_path File.expand_path(File.join(File.dirname(__FILE__), 'mocks')) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
timezone-0.99.2 | test/geonames_lookup_test.rb |
timezone-0.99.1 | test/geonames_lookup_test.rb |
timezone-0.99.0 | test/geonames_lookup_test.rb |