diff options
author | rick <technoweenie@gmail.com> | 2008-08-26 11:53:33 -0700 |
---|---|---|
committer | rick <technoweenie@gmail.com> | 2008-08-26 11:53:33 -0700 |
commit | 0aef9d1a2651fa0acd2adcd2de308eeb0ec8cdd2 (patch) | |
tree | 1a782151632dd80c8a18c3960536bdf8643debe3 /activesupport/test/i18n_test.rb | |
parent | 0a6d75dedd79407376aae1f01302164dfd3e44b6 (diff) | |
parent | 229eedfda87a7706dbb5e3e51af8707b3adae375 (diff) | |
download | rails-0aef9d1a2651fa0acd2adcd2de308eeb0ec8cdd2.tar.gz rails-0aef9d1a2651fa0acd2adcd2de308eeb0ec8cdd2.tar.bz2 rails-0aef9d1a2651fa0acd2adcd2de308eeb0ec8cdd2.zip |
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'activesupport/test/i18n_test.rb')
-rw-r--r-- | activesupport/test/i18n_test.rb | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/activesupport/test/i18n_test.rb b/activesupport/test/i18n_test.rb new file mode 100644 index 0000000000..4b17e3c523 --- /dev/null +++ b/activesupport/test/i18n_test.rb @@ -0,0 +1,75 @@ +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) + assert_equal Time.zone.now.strftime("%a, %d %b %Y %H:%M:%S %z"), I18n.localize(Time.zone.now) + end + end + + def test_date_localization_should_use_default_format + assert_equal @date.strftime("%Y-%m-%d"), I18n.localize(@date) + end + + def test_date_localization_with_default_format + assert_equal @date.strftime("%Y-%m-%d"), I18n.localize(@date, :format => :default) + end + + def test_date_localization_with_short_format + assert_equal @date.strftime("%b %d"), I18n.localize(@date, :format => :short) + end + + def test_date_localization_with_long_format + assert_equal @date.strftime("%B %d, %Y"), I18n.localize(@date, :format => :long) + end + + def test_time_localization_should_use_default_format + assert_equal @time.strftime("%a, %d %b %Y %H:%M:%S %z"), I18n.localize(@time) + end + + def test_time_localization_with_default_format + assert_equal @time.strftime("%a, %d %b %Y %H:%M:%S %z"), I18n.localize(@time, :format => :default) + end + + def test_time_localization_with_short_format + assert_equal @time.strftime("%d %b %H:%M"), I18n.localize(@time, :format => :short) + end + + def test_time_localization_with_long_format + assert_equal @time.strftime("%B %d, %Y %H:%M"), I18n.localize(@time, :format => :long) + 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 |