2008-07-02 13:21:07 -04:00
|
|
|
require 'abstract_unit'
|
|
|
|
|
|
|
|
class I18nTest < Test::Unit::TestCase
|
|
|
|
def setup
|
|
|
|
@date = Date.parse("2008-7-2")
|
|
|
|
@time = Time.utc(2008, 7, 2, 16, 47, 1)
|
|
|
|
end
|
|
|
|
|
|
|
|
uses_mocha 'I18nTimeZoneTest' do
|
|
|
|
def test_time_zone_localization_with_default_format
|
|
|
|
Time.zone.stubs(:now).returns Time.local(2000)
|
2008-07-16 13:51:48 -04:00
|
|
|
assert_equal Time.zone.now.strftime("%a, %d %b %Y %H:%M:%S %z"), I18n.localize(Time.zone.now)
|
2008-07-02 13:21:07 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_date_localization_should_use_default_format
|
2008-07-16 13:51:48 -04:00
|
|
|
assert_equal @date.strftime("%Y-%m-%d"), I18n.localize(@date)
|
2008-07-02 13:21:07 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_date_localization_with_default_format
|
2008-07-16 13:51:48 -04:00
|
|
|
assert_equal @date.strftime("%Y-%m-%d"), I18n.localize(@date, :format => :default)
|
2008-07-02 13:21:07 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_date_localization_with_short_format
|
2008-07-16 13:51:48 -04:00
|
|
|
assert_equal @date.strftime("%b %d"), I18n.localize(@date, :format => :short)
|
2008-07-02 13:21:07 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_date_localization_with_long_format
|
2008-07-16 13:51:48 -04:00
|
|
|
assert_equal @date.strftime("%B %d, %Y"), I18n.localize(@date, :format => :long)
|
2008-07-02 13:21:07 -04:00
|
|
|
end
|
|
|
|
|
2008-07-16 13:51:48 -04:00
|
|
|
def test_time_localization_should_use_default_format
|
|
|
|
assert_equal @time.strftime("%a, %d %b %Y %H:%M:%S %z"), I18n.localize(@time)
|
2008-07-02 13:21:07 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_time_localization_with_default_format
|
2008-07-16 13:51:48 -04:00
|
|
|
assert_equal @time.strftime("%a, %d %b %Y %H:%M:%S %z"), I18n.localize(@time, :format => :default)
|
2008-07-02 13:21:07 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_time_localization_with_short_format
|
2008-07-16 13:51:48 -04:00
|
|
|
assert_equal @time.strftime("%d %b %H:%M"), I18n.localize(@time, :format => :short)
|
2008-07-02 13:21:07 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_time_localization_with_long_format
|
2008-07-16 13:51:48 -04:00
|
|
|
assert_equal @time.strftime("%B %d, %Y %H:%M"), I18n.localize(@time, :format => :long)
|
2008-07-02 13:21:07 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_day_names
|
|
|
|
assert_equal Date::DAYNAMES, I18n.translate(:'date.day_names')
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_abbr_day_names
|
|
|
|
assert_equal Date::ABBR_DAYNAMES, I18n.translate(:'date.abbr_day_names')
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_month_names
|
|
|
|
assert_equal Date::MONTHNAMES, I18n.translate(:'date.month_names')
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_abbr_month_names
|
|
|
|
assert_equal Date::ABBR_MONTHNAMES, I18n.translate(:'date.abbr_month_names')
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_date_order
|
|
|
|
assert_equal [:year, :month, :day], I18n.translate(:'date.order')
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_time_am
|
|
|
|
assert_equal 'am', I18n.translate(:'time.am')
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_time_pm
|
|
|
|
assert_equal 'pm', I18n.translate(:'time.pm')
|
|
|
|
end
|
|
|
|
end
|