diff options
author | Sven Fuchs <svenfuchs@artweb-design.de> | 2008-07-16 04:16:08 +0200 |
---|---|---|
committer | Sven Fuchs <svenfuchs@artweb-design.de> | 2008-07-16 04:16:08 +0200 |
commit | fbe1823117c6170e26b328ce192a2fc0945af533 (patch) | |
tree | de3cc65c11fc310fa4c37dc73c926f6b8f712324 /activesupport/lib/active_support/vendor/i18n-0.0.1/test/i18n_exceptions_test.rb | |
parent | 731fca8cf68ddb6d6b9670538a4686ada6b14b26 (diff) | |
download | rails-fbe1823117c6170e26b328ce192a2fc0945af533.tar.gz rails-fbe1823117c6170e26b328ce192a2fc0945af533.tar.bz2 rails-fbe1823117c6170e26b328ce192a2fc0945af533.zip |
add i18n lib files
Diffstat (limited to 'activesupport/lib/active_support/vendor/i18n-0.0.1/test/i18n_exceptions_test.rb')
-rw-r--r-- | activesupport/lib/active_support/vendor/i18n-0.0.1/test/i18n_exceptions_test.rb | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/vendor/i18n-0.0.1/test/i18n_exceptions_test.rb b/activesupport/lib/active_support/vendor/i18n-0.0.1/test/i18n_exceptions_test.rb new file mode 100644 index 0000000000..1ea1601681 --- /dev/null +++ b/activesupport/lib/active_support/vendor/i18n-0.0.1/test/i18n_exceptions_test.rb @@ -0,0 +1,100 @@ +$:.unshift "lib" + +require 'rubygems' +require 'test/unit' +require 'mocha' +require 'i18n' +require 'active_support' + +class I18nExceptionsTest < Test::Unit::TestCase + def test_invalid_locale_stores_locale + force_invalid_locale + rescue I18n::ArgumentError => e + assert_nil e.locale + end + + def test_invalid_locale_message + force_invalid_locale + rescue I18n::ArgumentError => e + assert_equal 'nil is not a valid locale', e.message + end + + def test_missing_translation_data_stores_locale_key_and_options + force_missing_translation_data + rescue I18n::ArgumentError => e + options = {:scope => :bar} + assert_equal 'de-DE', e.locale + assert_equal :foo, e.key + assert_equal options, e.options + end + + def test_missing_translation_data_message + force_missing_translation_data + rescue I18n::ArgumentError => e + assert_equal 'translation missing: de-DE, bar, foo', e.message + end + + 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 + + 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 + + def test_missing_interpolation_argument_stores_key_and_string + force_missing_interpolation_argument + rescue I18n::ArgumentError => e + assert_equal 'bar', e.key + assert_equal "{{bar}}", e.string + end + + def test_missing_interpolation_argument_message + force_missing_interpolation_argument + rescue I18n::ArgumentError => e + assert_equal 'interpolation argument bar missing in "{{bar}}"', e.message + end + + 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 + + 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 + + private + def force_invalid_locale + I18n.backend.translate nil, :foo + end + + def force_missing_translation_data + I18n.store_translations 'de-DE', :bar => nil + I18n.backend.translate 'de-DE', :foo, :scope => :bar + end + + def force_invalid_pluralization_data + I18n.store_translations 'de-DE', :foo => [:bar] + I18n.backend.translate 'de-DE', :foo, :count => 1 + end + + def force_missing_interpolation_argument + I18n.store_translations 'de-DE', :foo => "{{bar}}" + I18n.backend.translate 'de-DE', :foo, :baz => 'baz' + end + + def force_reserved_interpolation_key + I18n.store_translations 'de-DE', :foo => "{{scope}}" + I18n.backend.translate 'de-DE', :foo, :baz => 'baz' + end +end
\ No newline at end of file |