# encoding: utf-8 require 'test_helper' require 'uncharted' class TestCountry < MiniTest::Unit::TestCase def setup @br = Uncharted::Country.find('BR') end def test_country_lookup assert @br, "BR must exist" assert_equal 'BR', @br.alpha2 assert_equal 'BRA', @br.alpha3 assert_equal 'Brazil', @br.name end def test_country_find @us = Country.find('US') assert_equal [@br, @us], Country.find([@br.alpha2, @us.alpha2]) assert_equal @us, Country.find(@us) end def test_to_s assert_equal 'BR', @br.to_s end def test_country_count assert_equal 247, Country.count assert_equal 27, Country.subdivisions.values.count end def test_territories df = Territory.find('BR-DF') assert_equal [df], @br.districts assert_equal 26, @br.states.count assert_equal 27, @br.subdivisions.count assert @br.territories.empty? assert_equal 'ParanĂ¡', Uncharted::Territory.find('BR-PR').name assert_equal 'PR', Uncharted::Territory.find('BR-PR').abbr assert_equal 'PR', Uncharted::Territory.find('BR-PR').to_s end def test_classes assert_equal Country, Uncharted::Country assert_equal Territory, Uncharted::Territory assert_equal Country::Field, Uncharted::Country::Field assert_equal Territory::Field, Uncharted::Territory::Field end def test_country_collection assert_equal 247, Country.countries.count end end