Sha256: 5b1f78969a5279fc8fa837fe079b2a473c4aab0f4ccb44be375bd845eb3c7549

Contents?: true

Size: 1.04 KB

Versions: 107

Compression:

Stored size: 1.04 KB

Contents

require 'test_helper'

class I18nLoadPathTest < I18n::TestCase
  def setup
    super
    I18n.locale = :en
    I18n.backend = I18n::Backend::Simple.new
    store_translations(:en, :foo => {:bar => 'bar', :baz => 'baz'})
  end

  test "nested load paths do not break locale loading" do
    I18n.load_path = [[locales_dir + '/en.yml']]
    assert_equal "baz", I18n.t(:'foo.bar')
  end

  test "loading an empty yml file raises an InvalidLocaleData exception" do
    assert_raise I18n::InvalidLocaleData do
      I18n.load_path = [[locales_dir + '/invalid/empty.yml']]
      I18n.t(:'foo.bar', :default => "baz")
    end
  end

  test "loading an invalid yml file raises an InvalidLocaleData exception" do
    assert_raise I18n::InvalidLocaleData do
      I18n.load_path = [[locales_dir + '/invalid/syntax.yml']]
      I18n.t(:'foo.bar', :default => "baz")
    end
  end

  test "adding arrays of filenames to the load path does not break locale loading" do
    I18n.load_path << Dir[locales_dir + '/*.{rb,yml}']
    assert_equal "baz", I18n.t(:'foo.bar')
  end
end

Version data entries

107 entries across 94 versions & 22 rubygems

Version Path
lazy_record-0.1.8 vendor/bundle/gems/i18n-0.8.1/test/i18n/load_path_test.rb
lazy_record-0.1.7 vendor/bundle/gems/i18n-0.8.1/test/i18n/load_path_test.rb
lazy_record-0.1.6 vendor/bundle/gems/i18n-0.8.1/test/i18n/load_path_test.rb
lazy_record-0.1.4 vendor/bundle/gems/i18n-0.8.1/test/i18n/load_path_test.rb
tdiary-5.0.4 vendor/bundle/gems/i18n-0.8.1/test/i18n/load_path_test.rb
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/i18n-0.8.1/test/i18n/load_path_test.rb
lazy_record-0.1.3 vendor/bundle/gems/i18n-0.8.1/test/i18n/load_path_test.rb
lazy_record-0.1.2 vendor/bundle/gems/i18n-0.8.1/test/i18n/load_path_test.rb
lazy_record-0.1.1 vendor/bundle/gems/i18n-0.8.1/test/i18n/load_path_test.rb
lazy_record-0.1.0 vendor/bundle/gems/i18n-0.8.1/test/i18n/load_path_test.rb
i18n-0.8.1 test/i18n/load_path_test.rb
i18n-0.8.0 test/i18n/load_path_test.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/i18n-0.7.0/test/i18n/load_path_test.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/i18n-0.7.0/test/i18n/load_path_test.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/i18n-0.7.0/test/i18n/load_path_test.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/i18n-0.7.0/test/i18n/load_path_test.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/i18n-0.7.0/test/i18n/load_path_test.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/i18n-0.7.0/test/i18n/load_path_test.rb
autocompl-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/i18n-0.7.0/test/i18n/load_path_test.rb
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/i18n-0.7.0/test/i18n/load_path_test.rb