Class: I18nSimpleBackendLocalizeDateTimeTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Includes:
I18nSimpleBackendTestSetup
Defined in:
lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb

Instance Method Summary collapse

Methods included from I18nSimpleBackendTestSetup

#add_datetime_translations, #backend_get_translations, #setup_backend

Instance Method Details

#setupObject



365
366
367
368
369
370
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 365

def setup
  @backend = I18n::Backend::Simple.new
  add_datetime_translations
  @morning = DateTime.new 2008, 1, 1, 6
  @evening = DateTime.new 2008, 1, 1, 18
end

#test_translate_given_a_day_name_format_it_returns_the_correct_day_nameObject



384
385
386
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 384

def test_translate_given_a_day_name_format_it_returns_the_correct_day_name
  assert_equal 'Dienstag', @backend.localize('de', @morning, '%A')
end

#test_translate_given_a_meridian_indicator_format_it_returns_the_correct_meridian_indicatorObject



400
401
402
403
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 400

def test_translate_given_a_meridian_indicator_format_it_returns_the_correct_meridian_indicator
  assert_equal 'am', @backend.localize('de', @morning, '%p')
  assert_equal 'pm', @backend.localize('de', @evening, '%p')
end

#test_translate_given_a_month_name_format_it_returns_the_correct_month_nameObject



392
393
394
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 392

def test_translate_given_a_month_name_format_it_returns_the_correct_month_name
  assert_equal 'Januar', @backend.localize('de', @morning, '%B')
end

#test_translate_given_an_abbr_day_name_format_it_returns_the_correct_abbrevated_day_nameObject



388
389
390
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 388

def test_translate_given_an_abbr_day_name_format_it_returns_the_correct_abbrevated_day_name
  assert_equal 'Di', @backend.localize('de', @morning, '%a')
end

#test_translate_given_an_abbr_month_name_format_it_returns_the_correct_abbrevated_month_nameObject



396
397
398
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 396

def test_translate_given_an_abbr_month_name_format_it_returns_the_correct_abbrevated_month_name
  assert_equal 'Jan', @backend.localize('de', @morning, '%b')
end

#test_translate_given_an_unknown_format_it_does_not_failObject



409
410
411
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 409

def test_translate_given_an_unknown_format_it_does_not_fail
  assert_nothing_raised{ @backend.localize 'de', @morning, '%x' }
end

#test_translate_given_no_format_it_does_not_failObject



405
406
407
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 405

def test_translate_given_no_format_it_does_not_fail
  assert_nothing_raised{ @backend.localize 'de', @morning }
end

#test_translate_given_the_default_format_it_uses_itObject



380
381
382
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 380

def test_translate_given_the_default_format_it_uses_it
  assert_equal 'Di, 01. Jan 2008 06:00:00 +0000', @backend.localize('de', @morning, :default)
end

#test_translate_given_the_long_format_it_uses_itObject



376
377
378
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 376

def test_translate_given_the_long_format_it_uses_it
  assert_equal '01. Januar 2008 06:00', @backend.localize('de', @morning, :long)
end

#test_translate_given_the_short_format_it_uses_itObject



372
373
374
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 372

def test_translate_given_the_short_format_it_uses_it
  assert_equal '01. Jan 06:00', @backend.localize('de', @morning, :short)
end