/
time.rb
63 lines (51 loc) · 2.62 KB
/
time.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# encoding: utf-8
module Tests
module Backend
module Api
module Localization
module Time
# TODO should be Mrz, shouldn't it?
def test_localize_given_the_short_format_it_uses_it
assert_equal '01. Mar 06:00', I18n.backend.localize('de', morning_time, :short)
end
def test_localize_given_the_long_format_it_uses_it
assert_equal '01. März 2008 06:00', I18n.backend.localize('de', morning_time, :long)
end
# TODO Seems to break on Windows because ENV['TZ'] is ignored. What's a better way to do this?
# def test_localize_given_the_default_format_it_uses_it
# assert_equal 'Sa, 01. Mar 2008 06:00:00 +0000', I18n.backend.localize('de', morning_time, :default)
# end
def test_localize_given_a_day_name_format_it_returns_the_correct_day_name
assert_equal 'Samstag', I18n.backend.localize('de', morning_time, '%A')
end
def test_localize_given_an_abbr_day_name_format_it_returns_the_correct_abbrevated_day_name
assert_equal 'Sa', I18n.backend.localize('de', morning_time, '%a')
end
def test_localize_given_a_month_name_format_it_returns_the_correct_month_name
assert_equal 'März', I18n.backend.localize('de', morning_time, '%B')
end
# TODO should be Mrz, shouldn't it?
def test_localize_given_an_abbr_month_name_format_it_returns_the_correct_abbrevated_month_name
assert_equal 'Mar', I18n.backend.localize('de', morning_time, '%b')
end
def test_localize_given_a_meridian_indicator_format_it_returns_the_correct_meridian_indicator
assert_equal 'am', I18n.backend.localize('de', morning_time, '%p')
assert_equal 'pm', I18n.backend.localize('de', evening_time, '%p')
end
def test_localize_given_a_format_specified_as_a_proc
assert_equal '1ter März 2008, 06:00 Uhr', I18n.backend.localize('de', morning_time, :long_ordinalized)
end
def test_localize_given_a_format_specified_as_a_proc_with_additional_options
assert_equal '1ter März 2008, 06:00 Uhr (MEZ)', I18n.backend.localize('de', morning_time, :long_ordinalized, :timezone => 'MEZ')
end
def test_localize_given_no_format_it_does_not_fail
assert_nothing_raised{ I18n.backend.localize 'de', morning_time }
end
def test_localize_given_an_unknown_format_it_does_not_fail
assert_nothing_raised{ I18n.backend.localize 'de', morning_time, '%x' }
end
end
end
end
end
end