Class: I18nSimpleBackendLoadTranslationsTest

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

#test_load_rb_loads_data_from_ruby_fileObject



496
497
498
499
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 496

def test_load_rb_loads_data_from_ruby_file
  data = @backend.send :load_rb, "#{@locale_dir}/en.rb"
  assert_equal({:'en-Ruby' => {:foo => {:bar => "baz"}}}, data)
end

#test_load_rb_loads_data_from_yaml_fileObject



501
502
503
504
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 501

def test_load_rb_loads_data_from_yaml_file
  data = @backend.send :load_yml, "#{@locale_dir}/en.yml"
  assert_equal({'en-Yaml' => {'foo' => {'bar' => 'baz'}}}, data)
end

#test_load_translations_loads_from_different_file_formatsObject



506
507
508
509
510
511
512
513
514
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 506

def test_load_translations_loads_from_different_file_formats
  @backend = I18n::Backend::Simple.new
  @backend.load_translations "#{@locale_dir}/en.rb", "#{@locale_dir}/en.yml"
  expected = {
    :'en-Ruby' => {:foo => {:bar => "baz"}},
    :'en-Yaml' => {:foo => {:bar => "baz"}}
  }
  assert_equal expected, backend_get_translations
end

#test_load_translations_with_ruby_file_type_does_not_raise_exceptionObject



492
493
494
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 492

def test_load_translations_with_ruby_file_type_does_not_raise_exception
  assert_nothing_raised { @backend.load_translations "#{@locale_dir}/en.rb" }
end

#test_load_translations_with_unknown_file_type_raises_exceptionObject



488
489
490
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 488

def test_load_translations_with_unknown_file_type_raises_exception
  assert_raise(I18n::UnknownFileType) { @backend.load_translations "#{@locale_dir}/en.xml" }
end