File: test_helper.rb

package info (click to toggle)
ruby-i18n 0.6.0-3%2Bdeb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 592 kB
  • sloc: ruby: 4,306; makefile: 3
file content (56 lines) | stat: -rw-r--r-- 1,371 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
$KCODE = 'u' if RUBY_VERSION <= '1.9'

#require 'rubygems'
require 'test/unit'

# Do not load the i18n gem from libraries like active_support.
#
# This is required for testing against Rails 2.3 because active_support/vendor.rb#24 tries
# to load I18n using the gem method. Instead, we want to test the local library of course.
#alias :gem_for_ruby_19 :gem # for 1.9. gives a super ugly seg fault otherwise
#def gem(gem_name, *version_requirements)
#  gem_name =='i18n' ? puts("skipping loading the i18n gem ...") : super
#end

#require 'bundler/setup'
require 'i18n'
require 'mocha'
require 'test_declarative'

class Test::Unit::TestCase
  def teardown
    I18n.locale = nil
    I18n.default_locale = :en
    I18n.load_path = []
    I18n.available_locales = nil
    I18n.backend = nil
  end

  def translations
    I18n.backend.instance_variable_get(:@translations)
  end

  def store_translations(*args)
    data   = args.pop
    locale = args.pop || :en
    I18n.backend.store_translations(locale, data)
  end

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

module Kernel
  def setup_rufus_tokyo
    require 'rufus/tokyo'
  rescue LoadError => e
    puts "can't use KeyValue backend because: #{e.message}"
  end
end

Object.class_eval do
  def meta_class
    class << self; self; end
  end
end unless Object.method_defined?(:meta_class)