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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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