Sha256: dfeeb860437c646f884716da6c55333e6ec679951aea3fb667d7e5d9802712a4

Contents?: true

Size: 1 KB

Versions: 3

Compression:

Stored size: 1 KB

Contents

require 'timezone/configure'
require 'timezone/lookup/test'
require 'timezone/zone'
require 'minitest/autorun'

class TestLookupTest < ::Minitest::Unit::TestCase
  def setup
    Timezone::Configure.begin do |c|
      c.lookup = ::Timezone::Lookup::Test
    end
  end

  def test_simple_stub
    ::Timezone::Configure.lookup.stub(-10, 10, 'America/Los_Angeles')

    assert_equal(
      'America/Los_Angeles',
      ::Timezone::Zone.new(lat: -10, lon: 10).zone)
  end

  def test_missing_stub
    assert_raises(::Timezone::Error::Test) do
      ::Timezone::Zone.new(lat: 100, lon: 100)
    end
  end

  def test_clear_lookup
    ::Timezone::Configure.begin do |c|
      c.username = 'foo'
      c.lookup = nil
    end

    assert ::Timezone::Lookup::Geonames, ::Timezone::Configure.lookup.class
  end

  def teardown
    Timezone::Configure.instance_variable_set(:@lookup, nil)
    Timezone::Configure.instance_variable_set(:@google_lookup, nil)
    Timezone::Configure.instance_variable_set(:@geonames_lookup, nil)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
timezone-0.99.2 test/test_lookup_test.rb
timezone-0.99.1 test/test_lookup_test.rb
timezone-0.99.0 test/test_lookup_test.rb