mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
make i18n date/time tests timezone independent
This commit is contained in:
parent
2e74ddbd73
commit
0ac342fbe5
1 changed files with 10 additions and 10 deletions
|
@ -9,40 +9,40 @@ class I18nTest < Test::Unit::TestCase
|
||||||
uses_mocha 'I18nTimeZoneTest' do
|
uses_mocha 'I18nTimeZoneTest' do
|
||||||
def test_time_zone_localization_with_default_format
|
def test_time_zone_localization_with_default_format
|
||||||
Time.zone.stubs(:now).returns Time.local(2000)
|
Time.zone.stubs(:now).returns Time.local(2000)
|
||||||
assert_equal "Sat, 01 Jan 2000 00:00:00 +0100", I18n.localize(Time.zone.now)
|
assert_equal Time.zone.now.strftime("%a, %d %b %Y %H:%M:%S %z"), I18n.localize(Time.zone.now)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_date_localization_should_use_default_format
|
def test_date_localization_should_use_default_format
|
||||||
assert_equal "2008-07-02", I18n.localize(@date)
|
assert_equal @date.strftime("%Y-%m-%d"), I18n.localize(@date)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_date_localization_with_default_format
|
def test_date_localization_with_default_format
|
||||||
assert_equal "2008-07-02", I18n.localize(@date, :format => :default)
|
assert_equal @date.strftime("%Y-%m-%d"), I18n.localize(@date, :format => :default)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_date_localization_with_short_format
|
def test_date_localization_with_short_format
|
||||||
assert_equal "Jul 02", I18n.localize(@date, :format => :short)
|
assert_equal @date.strftime("%b %d"), I18n.localize(@date, :format => :short)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_date_localization_with_long_format
|
def test_date_localization_with_long_format
|
||||||
assert_equal "July 02, 2008", I18n.localize(@date, :format => :long)
|
assert_equal @date.strftime("%B %d, %Y"), I18n.localize(@date, :format => :long)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_time_localization_should_use_default_format
|
def test_time_localization_should_use_default_format
|
||||||
assert_equal "Wed, 02 Jul 2008 16:47:01 +0100", I18n.localize(@time)
|
assert_equal @time.strftime("%a, %d %b %Y %H:%M:%S %z"), I18n.localize(@time)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_time_localization_with_default_format
|
def test_time_localization_with_default_format
|
||||||
assert_equal "Wed, 02 Jul 2008 16:47:01 +0100", I18n.localize(@time, :format => :default)
|
assert_equal @time.strftime("%a, %d %b %Y %H:%M:%S %z"), I18n.localize(@time, :format => :default)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_time_localization_with_short_format
|
def test_time_localization_with_short_format
|
||||||
assert_equal "02 Jul 16:47", I18n.localize(@time, :format => :short)
|
assert_equal @time.strftime("%d %b %H:%M"), I18n.localize(@time, :format => :short)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_time_localization_with_long_format
|
def test_time_localization_with_long_format
|
||||||
assert_equal "July 02, 2008 16:47", I18n.localize(@time, :format => :long)
|
assert_equal @time.strftime("%B %d, %Y %H:%M"), I18n.localize(@time, :format => :long)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_day_names
|
def test_day_names
|
||||||
|
|
Loading…
Reference in a new issue