Class: I18nSimpleBackendLocalizeDateTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Includes:
I18nSimpleBackendTestSetup
Defined in:
lib/vendor/i18n/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



312
313
314
315
316
# File 'lib/vendor/i18n/test/simple_backend_test.rb', line 312

def setup
  @backend = I18n::Backend::Simple.new
  add_datetime_translations
  @date = Date.new 2008, 1, 1
end

#test_localize_nil_raises_argument_errorObject



354
355
356
# File 'lib/vendor/i18n/test/simple_backend_test.rb', line 354

def test_localize_nil_raises_argument_error
  assert_raises(I18n::ArgumentError) { @backend.localize 'de', nil }
end

#test_localize_object_raises_argument_errorObject



358
359
360
# File 'lib/vendor/i18n/test/simple_backend_test.rb', line 358

def test_localize_object_raises_argument_error
  assert_raises(I18n::ArgumentError) { @backend.localize 'de', Object.new }
end

#test_translate_given_a_day_name_format_it_returns_a_day_nameObject



330
331
332
# File 'lib/vendor/i18n/test/simple_backend_test.rb', line 330

def test_translate_given_a_day_name_format_it_returns_a_day_name
  assert_equal 'Dienstag', @backend.localize('de', @date, '%A')
end

#test_translate_given_a_month_name_format_it_returns_a_month_nameObject



338
339
340
# File 'lib/vendor/i18n/test/simple_backend_test.rb', line 338

def test_translate_given_a_month_name_format_it_returns_a_month_name
  assert_equal 'Januar', @backend.localize('de', @date, '%B')
end

#test_translate_given_an_abbr_day_name_format_it_returns_an_abbrevated_day_nameObject



334
335
336
# File 'lib/vendor/i18n/test/simple_backend_test.rb', line 334

def test_translate_given_an_abbr_day_name_format_it_returns_an_abbrevated_day_name
  assert_equal 'Di', @backend.localize('de', @date, '%a')
end

#test_translate_given_an_abbr_month_name_format_it_returns_an_abbrevated_month_nameObject



342
343
344
# File 'lib/vendor/i18n/test/simple_backend_test.rb', line 342

def test_translate_given_an_abbr_month_name_format_it_returns_an_abbrevated_month_name
  assert_equal 'Jan', @backend.localize('de', @date, '%b')
end

#test_translate_given_an_unknown_format_it_does_not_failObject



350
351
352
# File 'lib/vendor/i18n/test/simple_backend_test.rb', line 350

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

#test_translate_given_no_format_it_does_not_failObject



346
347
348
# File 'lib/vendor/i18n/test/simple_backend_test.rb', line 346

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

#test_translate_given_the_default_format_it_uses_itObject



326
327
328
# File 'lib/vendor/i18n/test/simple_backend_test.rb', line 326

def test_translate_given_the_default_format_it_uses_it
  assert_equal '01.01.2008', @backend.localize('de', @date, :default)
end

#test_translate_given_the_long_format_it_uses_itObject



322
323
324
# File 'lib/vendor/i18n/test/simple_backend_test.rb', line 322

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

#test_translate_given_the_short_format_it_uses_itObject



318
319
320
# File 'lib/vendor/i18n/test/simple_backend_test.rb', line 318

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