From 0ccb90b400705c135387f90b72475807e48fa21b Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Mon, 15 Nov 2010 10:52:43 +0100 Subject: [PATCH] fix localization tests for 1.8.7-p302 (wtf) --- lib/i18n/tests/localization/procs.rb | 28 ++++++++++++++++++++-------- lib/i18n/tests/localization/time.rb | 4 ++-- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/lib/i18n/tests/localization/procs.rb b/lib/i18n/tests/localization/procs.rb index d3764bba..93aedf4e 100644 --- a/lib/i18n/tests/localization/procs.rb +++ b/lib/i18n/tests/localization/procs.rb @@ -1,26 +1,38 @@ # encoding: utf-8 +class DateTime + def inspect + strftime('%a, %d %b %Y %H:%M:%S %Z') + end +end + +class Date + def inspect + strftime('%a, %d %b %Y') + end +end + module I18n module Tests module Localization module Procs test "localize: using day names from lambdas" do setup_time_proc_translations - time = ::Time.parse('2008-03-01 6:00 UTC') + time = ::Time.utc(2008, 3, 1, 6, 0) assert_match /Суббота/, I18n.l(time, :format => "%A, %d %B", :locale => :ru) assert_match /суббота/, I18n.l(time, :format => "%d %B (%A)", :locale => :ru) end test "localize: using month names from lambdas" do setup_time_proc_translations - time = ::Time.parse('2008-03-01 6:00 UTC') + time = ::Time.utc(2008, 3, 1, 6, 0) assert_match /марта/, I18n.l(time, :format => "%d %B %Y", :locale => :ru) assert_match /Март /, I18n.l(time, :format => "%B %Y", :locale => :ru) end test "localize: using abbreviated day names from lambdas" do setup_time_proc_translations - time = ::Time.parse('2008-03-01 6:00 UTC') + time = ::Time.utc(2008, 3, 1, 6, 0) assert_match /марта/, I18n.l(time, :format => "%d %b %Y", :locale => :ru) assert_match /март /, I18n.l(time, :format => "%b %Y", :locale => :ru) end @@ -40,24 +52,24 @@ module Procs test "localize DateTime: given a format that resolves to a Proc it calls the Proc with the object" do setup_time_proc_translations datetime = ::DateTime.new(2008, 3, 1, 6) - assert_equal '[Sat, 01 Mar 2008 06:00:00 +0000, {}]', I18n.l(datetime, :format => :proc, :locale => :ru) + assert_equal '[Sat, 01 Mar 2008 06:00:00 +00:00, {}]', I18n.l(datetime, :format => :proc, :locale => :ru) end test "localize DateTime: given a format that resolves to a Proc it calls the Proc with the object and extra options" do setup_time_proc_translations datetime = ::DateTime.new(2008, 3, 1, 6) - assert_equal '[Sat, 01 Mar 2008 06:00:00 +0000, {:foo=>"foo"}]', I18n.l(datetime, :format => :proc, :foo => 'foo', :locale => :ru) + assert_equal '[Sat, 01 Mar 2008 06:00:00 +00:00, {:foo=>"foo"}]', I18n.l(datetime, :format => :proc, :foo => 'foo', :locale => :ru) end test "localize Time: given a format that resolves to a Proc it calls the Proc with the object" do setup_time_proc_translations - time = ::Time.parse('2008-03-01 6:00 UTC') + time = ::Time.utc(2008, 3, 1, 6, 0) assert_equal [time, {}].inspect, I18n.l(time, :format => :proc, :locale => :ru) end test "localize Time: given a format that resolves to a Proc it calls the Proc with the object and extra options" do setup_time_proc_translations - time = ::Time.parse('2008-03-01 6:00 UTC') + time = ::Time.utc(2008, 3, 1, 6, 0) options = { :foo => 'foo' } assert_equal [time, options].inspect, I18n.l(time, options.merge(:format => :proc, :locale => :ru)) end @@ -65,7 +77,7 @@ module Procs protected def filter_args(*args) - args.map {|arg| arg.delete(:fallback) if arg.is_a?(Hash) ; arg }.inspect + args.map { |arg| arg.delete(:fallback) if arg.is_a?(Hash) ; arg }.inspect end def setup_time_proc_translations diff --git a/lib/i18n/tests/localization/time.rb b/lib/i18n/tests/localization/time.rb index 058a5f5b..599f21f5 100644 --- a/lib/i18n/tests/localization/time.rb +++ b/lib/i18n/tests/localization/time.rb @@ -7,8 +7,8 @@ module Time def setup super setup_time_translations - @time = ::Time.parse('2008-03-01 6:00 UTC') - @other_time = ::Time.parse('2008-03-01 18:00 UTC') + @time = ::Time.utc(2008, 3, 1, 6, 0) + @other_time = ::Time.utc(2008, 3, 1, 18, 0) end test "localize Time: given the short format it uses it" do