forked from svenfuchs/i18n-active_record
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_helper.rb
More file actions
56 lines (48 loc) · 1.26 KB
/
test_helper.rb
File metadata and controls
56 lines (48 loc) · 1.26 KB
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
require 'test_setup'
I18n::Tests.parse_options!
require 'bundler/setup'
$:.unshift File.expand_path("../lib", File.dirname(__FILE__))
require 'i18n/active_record'
require 'i18n/tests'
require 'mocha'
I18n::Tests.setup_active_record
class Test::Unit::TestCase
def self.test(name, &block)
test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
defined = instance_method(test_name) rescue false
raise "#{test_name} is already defined in #{self}" if defined
if block_given?
define_method(test_name, &block)
else
define_method(test_name) do
flunk "No implementation provided for #{name}"
end
end
end
def self.with_mocha
yield if Object.respond_to?(:expects)
end
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
Object.class_eval do
def meta_class
class << self; self; end
end
end unless Object.method_defined?(:meta_class)