Sha256: 2c0777bc1e46eff01a598e36b9014f78f8d72e846ca1e5321b5940d179559bfe

Contents?: true

Size: 929 Bytes

Versions: 26

Compression:

Stored size: 929 Bytes

Contents

require "test_helper"
require 'stringex'

class LocalizationI18nFailureTest < Test::Unit::TestCase
  def setup
    alias_i18n
    Stringex::Localization.reset!
  end

  def test_loading_i18n_backend_fails_if_no_i18n_module
    assert_raise(Stringex::Localization::Backend::I18nNotDefined) do
      Stringex::Localization.backend = :i18n
    end
  ensure
    unalias_i18n
  end

  def test_loading_i18n_backend_fails_if_i18n_defined_without_translate
    Object.send :const_set, :I18n, Module.new

    assert_raise(Stringex::Localization::Backend::I18nMissingTranslate) do
      Stringex::Localization.backend = :i18n
    end
  ensure
    Object.send :remove_const, :I18n
    unalias_i18n
  end

private

  def alias_i18n
    Object.send :const_set, :I18nBackup, I18n
    Object.send :remove_const, :I18n
  end

  def unalias_i18n
    Object.send :const_set, :I18n, I18nBackup
    Object.send :remove_const, :I18nBackup
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
stringex-2.8.6 test/unit/localization_18n_failure_test.rb
stringex-2.8.5 test/unit/localization_18n_failure_test.rb
stringex-2.8.4 test/unit/localization_18n_failure_test.rb
stringex-2.8.3 test/unit/localization_18n_failure_test.rb
stringex-2.8.2 test/unit/localization_18n_failure_test.rb
stringex-2.8.1 test/unit/localization_18n_failure_test.rb
stringex-2.7.1 test/unit/localization_18n_failure_test.rb
stringex-2.7.0 test/unit/localization_18n_failure_test.rb
stringex-2.6.1 test/unit/localization_18n_failure_test.rb
stringex-2.6.0 test/unit/localization_18n_failure_test.rb
stringex-2.5.2 test/unit/localization_18n_failure_test.rb
stringex-2.5.1 test/unit/localization_18n_failure_test.rb
stringex-2.5.0 test/unit/localization_18n_failure_test.rb
stringex-2.4.2 test/unit/localization_18n_failure_test.rb
stringex-2.4.1 test/unit/localization_18n_failure_test.rb
stringex-2.3.0 test/unit/localization_18n_failure_test.rb
stringex-2.2.2 test/unit/localization_18n_failure_test.rb
stringex-2.2.1 test/unit/localization_18n_failure_test.rb
stringex-2.2.0 test/unit/localization_18n_failure_test.rb
stringex-2.1.2 test/unit/localization_18n_failure_test.rb