Added mcollective 2.3.1 package
[packages/trusty/mcollective.git] / lib / mcollective / vendor / i18n / lib / i18n / tests / localization / time.rb
1 # encoding: utf-8
2
3 module I18n
4   module Tests
5     module Localization
6       module Time
7         def setup
8           super
9           setup_time_translations
10           @time = ::Time.utc(2008, 3, 1, 6, 0)
11           @other_time = ::Time.utc(2008, 3, 1, 18, 0)
12         end
13
14         test "localize Time: given the short format it uses it" do
15           # TODO should be Mrz, shouldn't it?
16           assert_equal '01. Mar 06:00', I18n.l(@time, :format => :short, :locale => :de)
17         end
18
19         test "localize Time: given the long format it uses it" do
20           assert_equal '01. März 2008 06:00', I18n.l(@time, :format => :long, :locale => :de)
21         end
22
23         # TODO Seems to break on Windows because ENV['TZ'] is ignored. What's a better way to do this?
24         # def test_localize_given_the_default_format_it_uses_it
25         #   assert_equal 'Sa, 01. Mar 2008 06:00:00 +0000', I18n.l(@time, :format => :default, :locale => :de)
26         # end
27
28         test "localize Time: given a day name format it returns the correct day name" do
29           assert_equal 'Samstag', I18n.l(@time, :format => '%A', :locale => :de)
30         end
31
32         test "localize Time: given an abbreviated day name format it returns the correct abbreviated day name" do
33           assert_equal 'Sa', I18n.l(@time, :format => '%a', :locale => :de)
34         end
35
36         test "localize Time: given a month name format it returns the correct month name" do
37           assert_equal 'März', I18n.l(@time, :format => '%B', :locale => :de)
38         end
39
40         test "localize Time: given an abbreviated month name format it returns the correct abbreviated month name" do
41           # TODO should be Mrz, shouldn't it?
42           assert_equal 'Mar', I18n.l(@time, :format => '%b', :locale => :de)
43         end
44
45         test "localize Time: given a meridian indicator format it returns the correct meridian indicator" do
46           assert_equal 'am', I18n.l(@time, :format => '%p', :locale => :de)
47           assert_equal 'pm', I18n.l(@other_time, :format => '%p', :locale => :de)
48         end
49
50         test "localize Time: given an unknown format it does not fail" do
51           assert_nothing_raised { I18n.l(@time, :format => '%x') }
52         end
53
54         test "localize Time: given a format is missing it raises I18n::MissingTranslationData" do
55           assert_raise(I18n::MissingTranslationData) { I18n.l(@time, :format => :missing) }
56         end
57
58         protected
59
60           def setup_time_translations
61             I18n.backend.store_translations :de, {
62               :time => {
63                 :formats => {
64                   :default => "%a, %d. %b %Y %H:%M:%S %z",
65                   :short => "%d. %b %H:%M",
66                   :long => "%d. %B %Y %H:%M",
67                 },
68                 :am => 'am',
69                 :pm => 'pm'
70               }
71             }
72           end
73       end
74     end
75   end
76 end