6
require 'active_support'
8
class I18nExceptionsTest < Test::Unit::TestCase
9
def test_invalid_locale_stores_locale
11
rescue I18n::ArgumentError => e
15
def test_invalid_locale_message
17
rescue I18n::ArgumentError => e
18
assert_equal 'nil is not a valid locale', e.message
21
def test_missing_translation_data_stores_locale_key_and_options
22
force_missing_translation_data
23
rescue I18n::ArgumentError => e
24
options = {:scope => :bar}
25
assert_equal 'de', e.locale
26
assert_equal :foo, e.key
27
assert_equal options, e.options
30
def test_missing_translation_data_message
31
force_missing_translation_data
32
rescue I18n::ArgumentError => e
33
assert_equal 'translation missing: de, bar, foo', e.message
36
def test_invalid_pluralization_data_stores_entry_and_count
37
force_invalid_pluralization_data
38
rescue I18n::ArgumentError => e
39
assert_equal [:bar], e.entry
40
assert_equal 1, e.count
43
def test_invalid_pluralization_data_message
44
force_invalid_pluralization_data
45
rescue I18n::ArgumentError => e
46
assert_equal 'translation data [:bar] can not be used with :count => 1', e.message
49
def test_missing_interpolation_argument_stores_key_and_string
50
force_missing_interpolation_argument
51
rescue I18n::ArgumentError => e
52
assert_equal 'bar', e.key
53
assert_equal "{{bar}}", e.string
56
def test_missing_interpolation_argument_message
57
force_missing_interpolation_argument
58
rescue I18n::ArgumentError => e
59
assert_equal 'interpolation argument bar missing in "{{bar}}"', e.message
62
def test_reserved_interpolation_key_stores_key_and_string
63
force_reserved_interpolation_key
64
rescue I18n::ArgumentError => e
65
assert_equal 'scope', e.key
66
assert_equal "{{scope}}", e.string
69
def test_reserved_interpolation_key_message
70
force_reserved_interpolation_key
71
rescue I18n::ArgumentError => e
72
assert_equal 'reserved key "scope" used in "{{scope}}"', e.message
76
def force_invalid_locale
77
I18n.backend.translate nil, :foo
80
def force_missing_translation_data
81
I18n.backend.store_translations 'de', :bar => nil
82
I18n.backend.translate 'de', :foo, :scope => :bar
85
def force_invalid_pluralization_data
86
I18n.backend.store_translations 'de', :foo => [:bar]
87
I18n.backend.translate 'de', :foo, :count => 1
90
def force_missing_interpolation_argument
91
I18n.backend.store_translations 'de', :foo => "{{bar}}"
92
I18n.backend.translate 'de', :foo, :baz => 'baz'
95
def force_reserved_interpolation_key
96
I18n.backend.store_translations 'de', :foo => "{{scope}}"
97
I18n.backend.translate 'de', :foo, :baz => 'baz'
b'\\ No newline at end of file'