Class: I18nSimpleBackendLocalizeDateTest

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



311
312
313
314
315
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 311

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

#test_localize_nil_raises_argument_errorObject



353
354
355
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 353

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

#test_localize_object_raises_argument_errorObject



357
358
359
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 357

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

#test_translate_given_a_day_name_format_it_returns_a_day_nameObject



329
330
331
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 329

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



337
338
339
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 337

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



333
334
335
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 333

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



341
342
343
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 341

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



349
350
351
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 349

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



345
346
347
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 345

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



325
326
327
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 325

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



321
322
323
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 321

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



317
318
319
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 317

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