Sha256: 983acc2b0310a2f7f43089bd00f408117421966eb3ab72e59fe47334ef06d59a

Contents?: true

Size: 1.82 KB

Versions: 21

Compression:

Stored size: 1.82 KB

Contents

$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
require 'test/unit'
require 'tzinfo/country_index_definition'
require 'tzinfo/country_info'

include TZInfo

class TCCountryIndexDefinition < Test::Unit::TestCase

  module CountriesTest1     
    include CountryIndexDefinition
    
    country 'ZZ', 'Country One' do |c|
      raise 'Not a CountryInfo' unless c.kind_of?(CountryInfo)
      c.timezone 'Test/Zone/1', 3, 2, 41,20
    end
    
    country 'AA', 'Aland' do |c|
      raise 'Not a CountryInfo' unless c.kind_of?(CountryInfo)
      c.timezone 'Test/Zone/3', 71,30, 358, 15
      c.timezone 'Test/Zone/2', 41, 20, 211, 30
    end
    
    country 'TE', 'Three'    
  end
  
  module CountriesTest2
    include CountryIndexDefinition
    
    country 'CO', 'First Country' do |c|
      raise 'Not a CountryInfo' unless c.kind_of?(CountryInfo)
    end
  end
  
  def test_module_1
    hash = CountriesTest1.countries
    assert_equal(3, hash.length)
    assert_equal(true, hash.frozen?)
    
    zz = hash['ZZ']
    aa = hash['AA']
    te = hash['TE']
    
    assert_equal('ZZ', zz.code)
    assert_equal('Country One', zz.name)
    assert_equal(1, zz.zones.length)
    assert_equal('Test/Zone/1', zz.zones[0].identifier)
    
    assert_equal('AA', aa.code)
    assert_equal('Aland', aa.name)
    assert_equal(2, aa.zones.length)
    assert_equal('Test/Zone/3', aa.zones[0].identifier)
    assert_equal('Test/Zone/2', aa.zones[1].identifier)
    
    assert_equal('TE', te.code)
    assert_equal('Three', te.name)
    assert_equal(0, te.zones.length)    
  end
  
  def test_module_2
    hash = CountriesTest2.countries
    assert_equal(1, hash.length)
    assert_equal(true, hash.frozen?)
    
    co = hash['CO']
    
    assert_equal('CO', co.code)
    assert_equal('First Country', co.name)
    assert_equal(0, co.zones.length)
  end  
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
tzinfo-0.3.20 test/tc_country_index_definition.rb
tzinfo-0.3.19 test/tc_country_index_definition.rb
tzinfo-0.3.18 test/tc_country_index_definition.rb
tzinfo-0.3.17 test/tc_country_index_definition.rb
tzinfo-0.3.16 test/tc_country_index_definition.rb
tzinfo-0.3.15 test/tc_country_index_definition.rb
tzinfo-0.3.14 test/tc_country_index_definition.rb
tzinfo-0.3.0 test/tc_country_index_definition.rb
tzinfo-0.3.1 test/tc_country_index_definition.rb
tzinfo-0.3.10 test/tc_country_index_definition.rb
tzinfo-0.3.11 test/tc_country_index_definition.rb
tzinfo-0.3.12 test/tc_country_index_definition.rb
tzinfo-0.3.13 test/tc_country_index_definition.rb
tzinfo-0.3.2 test/tc_country_index_definition.rb
tzinfo-0.3.3 test/tc_country_index_definition.rb
tzinfo-0.3.4 test/tc_country_index_definition.rb
tzinfo-0.3.5 test/tc_country_index_definition.rb
tzinfo-0.3.6 test/tc_country_index_definition.rb
tzinfo-0.3.7 test/tc_country_index_definition.rb
tzinfo-0.3.8 test/tc_country_index_definition.rb