Sha256: 361e9df5a53a1d68f9b409e6786ab9341144b058ad714bf3c029f4683694c29e

Contents?: true

Size: 1.68 KB

Versions: 34

Compression:

Stored size: 1.68 KB

Contents

require 'test_helper'

class CountryTest < Test::Unit::TestCase
  include ActiveMerchant

  def test_country_from_hash
    country = Country.new(:name => 'Canada', :alpha2 => 'CA', :alpha3 => 'CAN', :numeric => '124')
    assert_equal 'CA', country.code(:alpha2).to_s
    assert_equal 'CAN', country.code(:alpha3).to_s
    assert_equal '124', country.code(:numeric).to_s
    assert_equal 'Canada', country.to_s
  end

  def test_country_for_alpha2_code
    country = Country.find('CA')
    assert_equal 'CA', country.code(:alpha2).to_s
    assert_equal 'CAN', country.code(:alpha3).to_s
    assert_equal '124', country.code(:numeric).to_s
    assert_equal 'Canada', country.to_s
  end
  
  def test_country_for_alpha3_code
    country = Country.find('CAN')
    assert_equal 'Canada', country.to_s
  end

  def test_country_for_numeric_code
    country = Country.find('124')
    assert_equal 'Canada', country.to_s
  end

  def test_find_country_by_name
    country = Country.find('Canada')
    assert_equal 'Canada', country.to_s
  end

  def test_find_unknown_country_name
    assert_raise(InvalidCountryCodeError) do
      Country.find('Asskickistan')
    end
  end
  
  def test_find_australia
    country = Country.find('AU')
    assert_equal 'AU', country.code(:alpha2).to_s
    
    country = Country.find('Australia')
    assert_equal 'AU', country.code(:alpha2).to_s
  end
  
  def test_find_united_kingdom
    country = Country.find('GB')
    assert_equal 'GB', country.code(:alpha2).to_s
    
    country = Country.find('United Kingdom')
    assert_equal 'GB', country.code(:alpha2).to_s
  end
  
  def test_raise_on_nil_name
    assert_raise(InvalidCountryCodeError) do
      Country.find(nil)
    end
  end
end

Version data entries

34 entries across 34 versions & 11 rubygems

Version Path
johnideal-activemerchant-1.4.10 test/unit/country_test.rb
johnideal-activemerchant-1.4.11 test/unit/country_test.rb
johnideal-activemerchant-1.4.4 test/unit/country_test.rb
johnideal-activemerchant-1.4.5 test/unit/country_test.rb
johnideal-activemerchant-1.4.6 test/unit/country_test.rb
johnideal-activemerchant-1.4.7 test/unit/country_test.rb
johnideal-activemerchant-1.4.8 test/unit/country_test.rb
mattbauer-activemerchant-1.4.2 test/unit/country_test.rb
tomriley-active_merchant-1.4.2.3 test/unit/country_test.rb
tomriley-active_merchant-1.4.2.4 test/unit/country_test.rb
tomriley-active_merchant-1.4.2.5 test/unit/country_test.rb
tomriley-active_merchant-1.4.2.6 test/unit/country_test.rb
tomriley-active_merchant-1.4.2.7 test/unit/country_test.rb
tomriley-active_merchant-1.4.2.8 test/unit/country_test.rb
tomriley-tomriley-active_merchant-1.4.2.4 test/unit/country_test.rb
goldstar-activemerchant-1.4.2.7 test/unit/country_test.rb
goldstar-activemerchant-1.4.2.6 test/unit/country_test.rb
tomriley-active_merchant-1.4.2.11 test/unit/country_test.rb
tomriley-active_merchant-1.4.2.10 test/unit/country_test.rb
smulube-activemerchant-1.5.1.4 test/unit/country_test.rb