File: test_helper.rb

package info (click to toggle)
ruby-i18n 1.8.10-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 704 kB
  • sloc: ruby: 5,836; makefile: 5
file content (61 lines) | stat: -rw-r--r-- 1,215 bytes parent folder | download
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
require 'minitest/autorun'
TEST_CASE = defined?(Minitest::Test) ? Minitest::Test : MiniTest::Unit::TestCase

# TODO: Remove these aliases and update tests accordingly.
class TEST_CASE
  alias :assert_raise :assert_raises
  alias :assert_not_equal :refute_equal

  def assert_nothing_raised(*args)
    yield
  end
end

gem "i18n"
require 'i18n'
require 'mocha/setup'
require 'test_declarative'

class I18n::TestCase < TEST_CASE
  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)
    I18n.backend.store_translations(locale, data)
  end

  def locales_dir
    File.dirname(__FILE__) + '/test_data/locales'
  end
end

class DummyRackApp
  def call(env)
    I18n.locale = :es
  end
end