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.1.1 test/unit/localization_18n_failure_test.rb
stringex-2.1.0 test/unit/localization_18n_failure_test.rb
stringex-2.0.11 test/unit/localization_18n_failure_test.rb
stringex-2.0.10 test/unit/localization_18n_failure_test.rb
stringex-2.0.9 test/unit/localization_18n_failure_test.rb
stringex-2.0.8 test/unit/localization_18n_failure_test.rb