Class: I18nSimpleBackendTranslateTest
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- I18nSimpleBackendTranslateTest
show all
- Includes:
- I18nSimpleBackendTestSetup
- Defined in:
- lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb
Instance Method Summary
collapse
#add_datetime_translations, #backend_get_translations, #setup_backend
Instance Method Details
#test_given_no_keys_it_returns_the_default ⇒ Object
144
145
146
|
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 144
def test_given_no_keys_it_returns_the_default
assert_equal 'default', @backend.translate('en', nil, :default => 'default')
end
|
#test_translate_an_array_of_keys_translates_all_of_them ⇒ Object
162
163
164
|
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 162
def test_translate_an_array_of_keys_translates_all_of_them
assert_equal %w(bar baz), @backend.translate('en', [:bar, :baz], :scope => [:foo])
end
|
#test_translate_calls_interpolate ⇒ Object
171
172
173
174
|
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 171
def test_translate_calls_interpolate
@backend.expects(:interpolate).with 'en', 'bar', {}
@backend.translate 'en', :bar, :scope => [:foo]
end
|
#test_translate_calls_interpolate_including_count_as_a_value ⇒ Object
176
177
178
179
|
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 176
def test_translate_calls_interpolate_including_count_as_a_value
@backend.expects(:interpolate).with 'en', 'bar', {:count => 1}
@backend.translate 'en', :bar, :scope => [:foo], :count => 1
end
|
#test_translate_calls_lookup_with_locale_given ⇒ Object
139
140
141
142
|
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 139
def test_translate_calls_lookup_with_locale_given
@backend.expects(:lookup).with('de', :bar, [:foo]).returns 'bar'
@backend.translate 'de', :bar, :scope => [:foo]
end
|
#test_translate_calls_pluralize ⇒ Object
166
167
168
169
|
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 166
def test_translate_calls_pluralize
@backend.expects(:pluralize).with 'en', 'bar', 1
@backend.translate 'en', :bar, :scope => [:foo], :count => 1
end
|
#test_translate_given_a_symbol_as_a_default_translates_the_symbol ⇒ Object
148
149
150
|
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 148
def test_translate_given_a_symbol_as_a_default_translates_the_symbol
assert_equal 'bar', @backend.translate('en', nil, :scope => [:foo], :default => :bar)
end
|
#test_translate_given_an_array_as_default_uses_the_first_match ⇒ Object
152
153
154
|
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 152
def test_translate_given_an_array_as_default_uses_the_first_match
assert_equal 'bar', @backend.translate('en', :does_not_exist, :scope => [:foo], :default => [:does_not_exist_2, :bar])
end
|
#test_translate_given_an_array_of_inexistent_keys_it_raises_missing_translation_data ⇒ Object
156
157
158
159
160
|
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 156
def test_translate_given_an_array_of_inexistent_keys_it_raises_missing_translation_data
assert_raise I18n::MissingTranslationData do
@backend.translate('en', :does_not_exist, :scope => [:foo], :default => [:does_not_exist_2, :does_not_exist_3])
end
end
|
#test_translate_given_nil_as_a_locale_raises_an_argument_error ⇒ Object
181
182
183
|
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 181
def test_translate_given_nil_as_a_locale_raises_an_argument_error
assert_raise(I18n::InvalidLocale){ @backend.translate nil, :bar }
end
|
#test_translate_with_a_bogus_key_and_no_default_raises_missing_translation_data ⇒ Object
185
186
187
|
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 185
def test_translate_with_a_bogus_key_and_no_default_raises_missing_translation_data
assert_raise(I18n::MissingTranslationData){ @backend.translate 'de', :bogus }
end
|