Class: I18nSimpleBackendInterpolateTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Includes:
I18nSimpleBackendTestSetup
Defined in:
lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb

Instance Method Summary collapse

Methods included from I18nSimpleBackendTestSetup

#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_encodingObject



265
266
267
# File 'lib/active_support/vendor/i18n-0.1.3/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_errorObject



275
276
277
278
279
# File 'lib/active_support/vendor/i18n-0.1.3/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_raise(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_keyObject



298
299
300
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 298

def test_interpolate_given_a_string_containing_a_reserved_key_raises_reserved_interpolation_key
  assert_raise(I18n::ReservedInterpolationKey) { @backend.send(:interpolate, nil, '{{default}}', {:default => nil}) }
end

#test_interpolate_given_a_value_hash_interpolates_into_unicode_stringObject



252
253
254
# File 'lib/active_support/vendor/i18n-0.1.3/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_stringObject



248
249
250
# File 'lib/active_support/vendor/i18n-0.1.3/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_stringObject



290
291
292
# File 'lib/active_support/vendor/i18n-0.1.3/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_argumentObject



294
295
296
# File 'lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb', line 294

def test_interpolate_given_an_empty_values_hash_raises_missing_interpolation_argument
  assert_raise(I18n::MissingInterpolationArgument) { @backend.send(:interpolate, nil, 'Hi {{name}}!', {}) }
end

#test_interpolate_given_an_non_string_as_a_string_returns_nilObject



286
287
288
# File 'lib/active_support/vendor/i18n-0.1.3/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_stringObject



260
261
262
# File 'lib/active_support/vendor/i18n-0.1.3/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_stringObject



256
257
258
# File 'lib/active_support/vendor/i18n-0.1.3/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_errorObject



269
270
271
272
273
# File 'lib/active_support/vendor/i18n-0.1.3/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_raise(Encoding::CompatibilityError) do
    @backend.send(:interpolate, nil, euc_jp('こんにちは、{{name}}さん!'), :name => 'ゆきひろ')
  end
end

#test_interpolate_given_nil_as_a_string_returns_nilObject



282
283
284
# File 'lib/active_support/vendor/i18n-0.1.3/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