Class: I18nSimpleBackendInterpolateTest
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- I18nSimpleBackendInterpolateTest
show all
- Includes:
- I18nSimpleBackendTestSetup
- Defined in:
- lib/vendor/i18n/test/simple_backend_test.rb
Instance Method Summary
collapse
#add_datetime_translations, #backend_get_translations, #setup_backend
Instance Method Details
#test_interpolate_given_a_non_unicode_multibyte_value_hash_interpolates_into_a_string_with_the_same_encoding ⇒ Object
265
266
267
|
# File 'lib/vendor/i18n/test/simple_backend_test.rb', line 265
def test_interpolate_given_a_non_unicode_multibyte_value_hash_interpolates_into_a_string_with_the_same_encoding
assert_equal euc_jp('Hi ゆきひろ!'), @backend.send(:interpolate, nil, 'Hi {{name}}!', :name => euc_jp('ゆきひろ'))
end
|
#test_interpolate_given_a_non_unicode_multibyte_value_hash_into_an_unicode_string_raises_encoding_compatibility_error ⇒ Object
275
276
277
278
279
|
# File 'lib/vendor/i18n/test/simple_backend_test.rb', line 275
def test_interpolate_given_a_non_unicode_multibyte_value_hash_into_an_unicode_string_raises_encoding_compatibility_error
assert_raises(Encoding::CompatibilityError) do
@backend.send(:interpolate, nil, 'こんにちは、{{name}}さん!', :name => euc_jp('ゆきひろ'))
end
end
|
#test_interpolate_given_a_string_containing_a_reserved_key_raises_reserved_interpolation_key ⇒ Object
298
299
300
|
# File 'lib/vendor/i18n/test/simple_backend_test.rb', line 298
def test_interpolate_given_a_string_containing_a_reserved_key_raises_reserved_interpolation_key
assert_raises(I18n::ReservedInterpolationKey) { @backend.send(:interpolate, nil, '{{default}}', {:default => nil}) }
end
|
#test_interpolate_given_a_value_hash_interpolates_into_unicode_string ⇒ Object
252
253
254
|
# File 'lib/vendor/i18n/test/simple_backend_test.rb', line 252
def test_interpolate_given_a_value_hash_interpolates_into_unicode_string
assert_equal 'Häi David!', @backend.send(:interpolate, nil, 'Häi {{name}}!', :name => 'David')
end
|
#test_interpolate_given_a_value_hash_interpolates_the_values_to_the_string ⇒ Object
248
249
250
|
# File 'lib/vendor/i18n/test/simple_backend_test.rb', line 248
def test_interpolate_given_a_value_hash_interpolates_the_values_to_the_string
assert_equal 'Hi David!', @backend.send(:interpolate, nil, 'Hi {{name}}!', :name => 'David')
end
|
#test_interpolate_given_a_values_hash_with_nil_values_interpolates_the_string ⇒ Object
290
291
292
|
# File 'lib/vendor/i18n/test/simple_backend_test.rb', line 290
def test_interpolate_given_a_values_hash_with_nil_values_interpolates_the_string
assert_equal 'Hi !', @backend.send(:interpolate, nil, 'Hi {{name}}!', {:name => nil})
end
|
#test_interpolate_given_an_empty_values_hash_raises_missing_interpolation_argument ⇒ Object
294
295
296
|
# File 'lib/vendor/i18n/test/simple_backend_test.rb', line 294
def test_interpolate_given_an_empty_values_hash_raises_missing_interpolation_argument
assert_raises(I18n::MissingInterpolationArgument) { @backend.send(:interpolate, nil, 'Hi {{name}}!', {}) }
end
|
#test_interpolate_given_an_non_string_as_a_string_returns_nil ⇒ Object
286
287
288
|
# File 'lib/vendor/i18n/test/simple_backend_test.rb', line 286
def test_interpolate_given_an_non_string_as_a_string_returns_nil
assert_equal [], @backend.send(:interpolate, nil, [], :name => 'David')
end
|
#test_interpolate_given_an_unicode_value_hash_interpolates_into_unicode_string ⇒ Object
260
261
262
|
# File 'lib/vendor/i18n/test/simple_backend_test.rb', line 260
def test_interpolate_given_an_unicode_value_hash_interpolates_into_unicode_string
assert_equal 'こんにちは、ゆきひろさん!', @backend.send(:interpolate, nil, 'こんにちは、{{name}}さん!', :name => 'ゆきひろ')
end
|
#test_interpolate_given_an_unicode_value_hash_interpolates_to_the_string ⇒ Object
256
257
258
|
# File 'lib/vendor/i18n/test/simple_backend_test.rb', line 256
def test_interpolate_given_an_unicode_value_hash_interpolates_to_the_string
assert_equal 'Hi ゆきひろ!', @backend.send(:interpolate, nil, 'Hi {{name}}!', :name => 'ゆきひろ')
end
|
#test_interpolate_given_an_unicode_value_hash_into_a_non_unicode_multibyte_string_raises_encoding_compatibility_error ⇒ Object
269
270
271
272
273
|
# File 'lib/vendor/i18n/test/simple_backend_test.rb', line 269
def test_interpolate_given_an_unicode_value_hash_into_a_non_unicode_multibyte_string_raises_encoding_compatibility_error
assert_raises(Encoding::CompatibilityError) do
@backend.send(:interpolate, nil, euc_jp('こんにちは、{{name}}さん!'), :name => 'ゆきひろ')
end
end
|
#test_interpolate_given_nil_as_a_string_returns_nil ⇒ Object
282
283
284
|
# File 'lib/vendor/i18n/test/simple_backend_test.rb', line 282
def test_interpolate_given_nil_as_a_string_returns_nil
assert_nil @backend.send(:interpolate, nil, nil, :name => 'David')
end
|