diff options
author | Luca Guidi <guidi.luca@gmail.com> | 2008-06-27 15:00:55 +0200 |
---|---|---|
committer | Luca Guidi <guidi.luca@gmail.com> | 2008-06-27 15:00:55 +0200 |
commit | 66c2508ebbca06e551255a76cc47a1608f091992 (patch) | |
tree | dbe69afc243393217635c1d564e28e5d7aa5cd6f /actionpack/test/template/date_helper_i18n_test.rb | |
parent | 8461526f346b8d8387ba3b74221fbeefef3aefeb (diff) | |
download | rails-66c2508ebbca06e551255a76cc47a1608f091992.tar.gz rails-66c2508ebbca06e551255a76cc47a1608f091992.tar.bz2 rails-66c2508ebbca06e551255a76cc47a1608f091992.zip |
Make sure mocha is available
Diffstat (limited to 'actionpack/test/template/date_helper_i18n_test.rb')
-rw-r--r-- | actionpack/test/template/date_helper_i18n_test.rb | 134 |
1 files changed, 69 insertions, 65 deletions
diff --git a/actionpack/test/template/date_helper_i18n_test.rb b/actionpack/test/template/date_helper_i18n_test.rb index 3e1eed61fd..aeb06c55ea 100644 --- a/actionpack/test/template/date_helper_i18n_test.rb +++ b/actionpack/test/template/date_helper_i18n_test.rb @@ -8,43 +8,45 @@ class DateHelperDistanceOfTimeInWordsI18nTests < Test::Unit::TestCase @from = Time.mktime(2004, 6, 6, 21, 45, 0) end - # distance_of_time_in_words + uses_mocha 'date_helper_distance_of_time_in_words_i18n_test' do + # distance_of_time_in_words - def test_distance_of_time_in_words_calls_i18n - { # with include_seconds - [2.seconds, true] => [:'less_than_x_seconds', 5], - [9.seconds, true] => [:'less_than_x_seconds', 10], - [19.seconds, true] => [:'less_than_x_seconds', 20], - [30.seconds, true] => [:'half_a_minute', nil], - [59.seconds, true] => [:'less_than_x_minutes', 1], - [60.seconds, true] => [:'x_minutes', 1], - - # without include_seconds - [29.seconds, false] => [:'less_than_x_minutes', 1], - [60.seconds, false] => [:'x_minutes', 1], - [44.minutes, false] => [:'x_minutes', 44], - [61.minutes, false] => [:'about_x_hours', 1], - [24.hours, false] => [:'x_days', 1], - [30.days, false] => [:'about_x_months', 1], - [60.days, false] => [:'x_months', 2], - [1.year, false] => [:'about_x_years', 1], - [3.years, false] => [:'over_x_years', 3] - - }.each do |passed, expected| - assert_distance_of_time_in_words_translates_key passed, expected + def test_distance_of_time_in_words_calls_i18n + { # with include_seconds + [2.seconds, true] => [:'less_than_x_seconds', 5], + [9.seconds, true] => [:'less_than_x_seconds', 10], + [19.seconds, true] => [:'less_than_x_seconds', 20], + [30.seconds, true] => [:'half_a_minute', nil], + [59.seconds, true] => [:'less_than_x_minutes', 1], + [60.seconds, true] => [:'x_minutes', 1], + + # without include_seconds + [29.seconds, false] => [:'less_than_x_minutes', 1], + [60.seconds, false] => [:'x_minutes', 1], + [44.minutes, false] => [:'x_minutes', 44], + [61.minutes, false] => [:'about_x_hours', 1], + [24.hours, false] => [:'x_days', 1], + [30.days, false] => [:'about_x_months', 1], + [60.days, false] => [:'x_months', 2], + [1.year, false] => [:'about_x_years', 1], + [3.years, false] => [:'over_x_years', 3] + + }.each do |passed, expected| + assert_distance_of_time_in_words_translates_key passed, expected + end end - end - - def assert_distance_of_time_in_words_translates_key(passed, expected) - diff, include_seconds = *passed - key, count = *expected - to = @from + diff - options = {:locale => 'en-US', :scope => :'datetime.distance_in_words'} - options[:count] = count if count - - I18n.expects(:t).with(key, options) - distance_of_time_in_words(@from, to, include_seconds, :locale => 'en-US') + def assert_distance_of_time_in_words_translates_key(passed, expected) + diff, include_seconds = *passed + key, count = *expected + to = @from + diff + + options = {:locale => 'en-US', :scope => :'datetime.distance_in_words'} + options[:count] = count if count + + I18n.expects(:t).with(key, options) + distance_of_time_in_words(@from, to, include_seconds, :locale => 'en-US') + end end end @@ -52,36 +54,38 @@ class DateHelperSelectTagsI18nTests < Test::Unit::TestCase include ActionView::Helpers::DateHelper attr_reader :request - def setup - I18n.stubs(:translate).with(:'date.month_names', 'en-US').returns Date::MONTHNAMES - end - - # select_month - - def test_select_month_given_use_month_names_option_does_not_translate_monthnames - I18n.expects(:translate).never - select_month(8, :locale => 'en-US', :use_month_names => Date::MONTHNAMES) - end - - def test_select_month_translates_monthnames - I18n.expects(:translate).with(:'date.month_names', 'en-US').returns Date::MONTHNAMES - select_month(8, :locale => 'en-US') - end - - def test_select_month_given_use_short_month_option_translates_abbr_monthnames - I18n.expects(:translate).with(:'date.abbr_month_names', 'en-US').returns Date::ABBR_MONTHNAMES - select_month(8, :locale => 'en-US', :use_short_month => true) - end - - # date_or_time_select - - def test_date_or_time_select_given_an_order_options_does_not_translate_order - I18n.expects(:translate).never - datetime_select('post', 'updated_at', :order => [:year, :month, :day], :locale => 'en-US') - end - - def test_date_or_time_select_given_no_order_options_translates_order - I18n.expects(:translate).with(:'date.order', 'en-US').returns [:year, :month, :day] - datetime_select('post', 'updated_at', :locale => 'en-US') + uses_mocha 'date_helper_select_tags_i18n_tests' do + def setup + I18n.stubs(:translate).with(:'date.month_names', 'en-US').returns Date::MONTHNAMES + end + + # select_month + + def test_select_month_given_use_month_names_option_does_not_translate_monthnames + I18n.expects(:translate).never + select_month(8, :locale => 'en-US', :use_month_names => Date::MONTHNAMES) + end + + def test_select_month_translates_monthnames + I18n.expects(:translate).with(:'date.month_names', 'en-US').returns Date::MONTHNAMES + select_month(8, :locale => 'en-US') + end + + def test_select_month_given_use_short_month_option_translates_abbr_monthnames + I18n.expects(:translate).with(:'date.abbr_month_names', 'en-US').returns Date::ABBR_MONTHNAMES + select_month(8, :locale => 'en-US', :use_short_month => true) + end + + # date_or_time_select + + def test_date_or_time_select_given_an_order_options_does_not_translate_order + I18n.expects(:translate).never + datetime_select('post', 'updated_at', :order => [:year, :month, :day], :locale => 'en-US') + end + + def test_date_or_time_select_given_no_order_options_translates_order + I18n.expects(:translate).with(:'date.order', 'en-US').returns [:year, :month, :day] + datetime_select('post', 'updated_at', :locale => 'en-US') + end end end
\ No newline at end of file |