Class: I18nExceptionsTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/vendor/i18n/test/i18n_exceptions_test.rb

Instance Method Summary collapse

Instance Method Details

#test_invalid_locale_messageObject



12
13
14
15
16
# File 'lib/vendor/i18n/test/i18n_exceptions_test.rb', line 12

def test_invalid_locale_message
  force_invalid_locale
rescue I18n::ArgumentError => e
  assert_equal 'nil is not a valid locale', e.message
end

#test_invalid_locale_stores_localeObject



6
7
8
9
10
# File 'lib/vendor/i18n/test/i18n_exceptions_test.rb', line 6

def test_invalid_locale_stores_locale
  force_invalid_locale
rescue I18n::ArgumentError => e
  assert_nil e.locale
end

#test_invalid_pluralization_data_messageObject



40
41
42
43
44
# File 'lib/vendor/i18n/test/i18n_exceptions_test.rb', line 40

def test_invalid_pluralization_data_message
  force_invalid_pluralization_data
rescue I18n::ArgumentError => e
  assert_equal 'translation data [:bar] can not be used with :count => 1', e.message
end

#test_invalid_pluralization_data_stores_entry_and_countObject



33
34
35
36
37
38
# File 'lib/vendor/i18n/test/i18n_exceptions_test.rb', line 33

def test_invalid_pluralization_data_stores_entry_and_count
  force_invalid_pluralization_data
rescue I18n::ArgumentError => e
  assert_equal [:bar], e.entry
  assert_equal 1, e.count
end

#test_missing_interpolation_argument_messageObject



54
55
56
57
58
# File 'lib/vendor/i18n/test/i18n_exceptions_test.rb', line 54

def test_missing_interpolation_argument_message
  force_missing_interpolation_argument
rescue I18n::ArgumentError => e
  assert_equal 'missing interpolation argument in "{{bar}}" ({:baz=>"baz"} given)', e.message
end

#test_missing_interpolation_argument_stores_key_and_stringObject



46
47
48
49
50
51
52
# File 'lib/vendor/i18n/test/i18n_exceptions_test.rb', line 46

def test_missing_interpolation_argument_stores_key_and_string
  assert_raises(I18n::MissingInterpolationArgument) { force_missing_interpolation_argument } 
  force_missing_interpolation_argument
rescue I18n::ArgumentError => e
  # assert_equal :bar, e.key
  assert_equal "{{bar}}", e.string
end

#test_missing_translation_data_messageObject



27
28
29
30
31
# File 'lib/vendor/i18n/test/i18n_exceptions_test.rb', line 27

def test_missing_translation_data_message
  force_missing_translation_data
rescue I18n::ArgumentError => e
  assert_equal 'translation missing: de, bar, foo', e.message
end

#test_missing_translation_data_stores_locale_key_and_optionsObject



18
19
20
21
22
23
24
25
# File 'lib/vendor/i18n/test/i18n_exceptions_test.rb', line 18

def test_missing_translation_data_stores_locale_key_and_options
  force_missing_translation_data
rescue I18n::ArgumentError => e
  options = {:scope => :bar}
  assert_equal 'de', e.locale
  assert_equal :foo, e.key
  assert_equal options, e.options
end

#test_reserved_interpolation_key_messageObject



67
68
69
70
71
# File 'lib/vendor/i18n/test/i18n_exceptions_test.rb', line 67

def test_reserved_interpolation_key_message
  force_reserved_interpolation_key
rescue I18n::ArgumentError => e
  assert_equal 'reserved key :scope used in "{{scope}}"', e.message
end

#test_reserved_interpolation_key_stores_key_and_stringObject



60
61
62
63
64
65
# File 'lib/vendor/i18n/test/i18n_exceptions_test.rb', line 60

def test_reserved_interpolation_key_stores_key_and_string
  force_reserved_interpolation_key
rescue I18n::ArgumentError => e
  assert_equal :scope, e.key
  assert_equal "{{scope}}", e.string
end