Sha256: 206646ae66b8a5d5b03b55786b3fda5341b196238078c6bed5959ebcad6d795d

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
require 'i18n/backend/fallbacks'

class I18nFallbacksBackendTest < Test::Unit::TestCase
  def setup
    I18n.backend = I18n::Backend::Simple.new
    I18n.backend.meta_class.send(:include, I18n::Backend::Fallbacks)
    backend_store_translations(:en, :foo => 'Foo')
  end

  define_method "test: fallbacks for :de are [:de, :en]" do
    assert_equal [:de, :en], I18n.fallbacks[:de]
  end
  
  define_method "test: still returns the English translation as usual" do
    assert_equal 'Foo', I18n.t(:foo, :locale => :en)
  end
  
  define_method "test: returns the English translation for a missing German translation" do
    assert_equal 'Foo', I18n.t(:foo, :locale => :de)
  end
  
  define_method "test: raises I18n::MissingTranslationData exception when no translation was found" do
    assert_raises(I18n::MissingTranslationData) { I18n.t(:bar, :locale => :en, :raise => true) }
    assert_raises(I18n::MissingTranslationData) { I18n.t(:bar, :locale => :de, :raise => true) }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
theoooo-i18n-0.2.1 test/backend/fallbacks/fallbacks_test.rb
theoooo-i18n-0.2.2 test/backend/fallbacks/fallbacks_test.rb