1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
require 'minitest/autorun'
gem "i18n"
require 'i18n'
require 'mocha/minitest'
require 'test_declarative'
class I18n::TestCase < Minitest::Test
def assert_nothing_raised(*args)
yield
end
def self.key_value?
defined?(ActiveSupport)
end
def setup
super
I18n.load_path = nil
I18n.enforce_available_locales = false
end
def teardown
I18n.locale = nil
I18n.default_locale = nil
I18n.load_path = nil
I18n.available_locales = nil
I18n.backend = nil
I18n.default_separator = nil
I18n.enforce_available_locales = true
I18n.fallbacks = nil if I18n.respond_to?(:fallbacks=)
super
end
protected
def translations
I18n.backend.instance_variable_get(:@translations)
end
def store_translations(locale, data, options = I18n::EMPTY_HASH)
I18n.backend.store_translations(locale, data, options)
end
def locales_dir
File.dirname(__FILE__) + '/test_data/locales'
end
def stub_const(klass, constant, new_value)
old_value = klass.const_get(constant)
klass.send(:remove_const, constant)
klass.const_set(constant, new_value)
yield
ensure
klass.send(:remove_const, constant)
klass.const_set(constant, old_value)
end
end
class DummyRackApp
def call(env)
I18n.locale = :es
end
end
|