Class: I18nSimpleBackendLoadTranslationsTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Includes:
Tests::Backend::Simple::Setup::Base
Defined in:
lib/vendor/i18n/test/backend/simple/translations_test.rb

Instance Method Summary collapse

Methods included from Tests::Backend::Simple::Setup::Base

#setup, #teardown

Instance Method Details

#test_load_rb_loads_data_from_ruby_fileObject



16
17
18
19
# File 'lib/vendor/i18n/test/backend/simple/translations_test.rb', line 16

def test_load_rb_loads_data_from_ruby_file
  data = I18n.backend.send :load_rb, "#{locales_dir}/en.rb"
  assert_equal({ :en => { :fuh => { :bah => 'bas' } } }, data)
end

#test_load_rb_loads_data_from_yaml_fileObject



21
22
23
24
# File 'lib/vendor/i18n/test/backend/simple/translations_test.rb', line 21

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

#test_load_translations_loads_from_different_file_formatsObject



26
27
28
29
30
31
# File 'lib/vendor/i18n/test/backend/simple/translations_test.rb', line 26

def test_load_translations_loads_from_different_file_formats
  I18n.backend = I18n::Backend::Simple.new
  I18n.backend.load_translations "#{locales_dir}/en.rb", "#{locales_dir}/en.yml"
  expected = { :en => { :fuh => { :bah => "bas" }, :foo => { :bar => "baz" } } }
  assert_equal expected, backend_get_translations
end

#test_load_translations_with_ruby_file_type_does_not_raise_exceptionObject



12
13
14
# File 'lib/vendor/i18n/test/backend/simple/translations_test.rb', line 12

def test_load_translations_with_ruby_file_type_does_not_raise_exception
  assert_nothing_raised { I18n.backend.load_translations "#{locales_dir}/en.rb" }
end

#test_load_translations_with_unknown_file_type_raises_exceptionObject



8
9
10
# File 'lib/vendor/i18n/test/backend/simple/translations_test.rb', line 8

def test_load_translations_with_unknown_file_type_raises_exception
  assert_raises(I18n::UnknownFileType) { I18n.backend.load_translations "#{locales_dir}/en.xml" }
end