countries_helper_test.rb
1.36 KB
require File.dirname(__FILE__) + '/../test_helper'
class CountriesHelperTest < Test::Unit::TestCase
def setup
@helper = CountriesHelper.new
end
attr_reader :helper
should 'provide ISO-3166 list of countries' do
assert_kind_of Array, CountriesHelper.countries
# test some familiar countries and trust the rest is OK.
assert CountriesHelper.countries.any? { |entry| entry.first == 'Brazil' }
assert CountriesHelper.countries.any? { |entry| entry.first == 'France' }
assert CountriesHelper.countries.any? { |entry| entry.first == 'Switzerland' }
end
should 'translate country names' do
CountriesHelper.stubs(:countries).returns([["Brazil", "BR"],["France", "FR"]])
helper.expects(:gettext).with("Brazil").returns("Brasil")
helper.expects(:gettext).with("France").returns("França")
assert_equal [["Brasil", "BR"], ["França", "FR"]], helper.countries
end
should 'sort alphabetically by the translated names' do
CountriesHelper.stubs(:countries).returns([["Brazil", "BR"], ["Argentina", "AR"]])
assert_equal [["Argentina", "AR"], ["Brazil", "BR"]], helper.countries
end
should 'sort respecting utf-8 ordering (or something like that)' do
CountriesHelper.stubs(:countries).returns([["Brazil", "BR"], ["Åland Islands", "AX"]])
assert_equal [["Åland Islands", "AX"], ["Brazil", "BR"]], helper.countries
end
end