diff --git a/test/api/all_features_test.rb b/test/api/all_features_test.rb index 74589b7f..a1799bd6 100644 --- a/test/api/all_features_test.rb +++ b/test/api/all_features_test.rb @@ -7,7 +7,7 @@ puts "not testing with Cache enabled because active_support can not be found" end -class I18nAllFeaturesApiTest < Test::Unit::TestCase +class I18nAllFeaturesApiTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::Metadata include I18n::Backend::Cache diff --git a/test/api/cascade_test.rb b/test/api/cascade_test.rb index a40587b3..4d9516c4 100644 --- a/test/api/cascade_test.rb +++ b/test/api/cascade_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nCascadeApiTest < Test::Unit::TestCase +class I18nCascadeApiTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::Cascade end diff --git a/test/api/chain_test.rb b/test/api/chain_test.rb index 0a61cb0a..f3dff1b5 100644 --- a/test/api/chain_test.rb +++ b/test/api/chain_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nApiChainTest < Test::Unit::TestCase +class I18nApiChainTest < I18n::TestCase def setup super I18n.backend = I18n::Backend::Chain.new(I18n::Backend::Simple.new, I18n.backend) diff --git a/test/api/fallbacks_test.rb b/test/api/fallbacks_test.rb index 31ebb003..e5ca5f20 100644 --- a/test/api/fallbacks_test.rb +++ b/test/api/fallbacks_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nFallbacksApiTest < Test::Unit::TestCase +class I18nFallbacksApiTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::Fallbacks end diff --git a/test/api/key_value_test.rb b/test/api/key_value_test.rb index 976ca6ba..6a8d405f 100644 --- a/test/api/key_value_test.rb +++ b/test/api/key_value_test.rb @@ -1,8 +1,8 @@ require 'test_helper' -I18n::Tests.setup_rufus_tokyo +I18n::TestCase.setup_rufus_tokyo -class I18nKeyValueApiTest < Test::Unit::TestCase +class I18nKeyValueApiTest < I18n::TestCase include I18n::Tests::Basics include I18n::Tests::Defaults include I18n::Tests::Interpolation diff --git a/test/api/memoize_test.rb b/test/api/memoize_test.rb index 8839ec8c..0304580a 100644 --- a/test/api/memoize_test.rb +++ b/test/api/memoize_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nMemoizeBackendWithSimpleApiTest < Test::Unit::TestCase +class I18nMemoizeBackendWithSimpleApiTest < I18n::TestCase include I18n::Tests::Basics include I18n::Tests::Defaults include I18n::Tests::Interpolation @@ -27,9 +27,9 @@ def setup end end -I18n::Tests.setup_rufus_tokyo +I18n::TestCase.setup_rufus_tokyo -class I18nMemoizeBackendWithKeyValueApiTest < Test::Unit::TestCase +class I18nMemoizeBackendWithKeyValueApiTest < I18n::TestCase include I18n::Tests::Basics include I18n::Tests::Defaults include I18n::Tests::Interpolation diff --git a/test/api/override_test.rb b/test/api/override_test.rb index 1f4e564e..67e1f068 100644 --- a/test/api/override_test.rb +++ b/test/api/override_test.rb @@ -1,22 +1,18 @@ require 'test_helper' -class I18nOverrideTest < Test::Unit::TestCase +class I18nOverrideTest < I18n::TestCase module OverrideInverse - def translate(*args) super(*args).reverse end alias :t :translate - end module OverrideSignature - def translate(*args) args.first + args[1] end alias :t :translate - end def setup @@ -44,5 +40,4 @@ def setup @I18n.extend OverrideSignature assert_equal 'HelloWelcome message on home page', @I18n.translate('Hello', 'Welcome message on home page', :tokenize => true) # tr8n example end - end diff --git a/test/api/pluralization_test.rb b/test/api/pluralization_test.rb index 5da3a5ef..53004beb 100644 --- a/test/api/pluralization_test.rb +++ b/test/api/pluralization_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nPluralizationApiTest < Test::Unit::TestCase +class I18nPluralizationApiTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::Pluralization end diff --git a/test/api/simple_test.rb b/test/api/simple_test.rb index 02d62058..3fd3a424 100644 --- a/test/api/simple_test.rb +++ b/test/api/simple_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nSimpleBackendApiTest < Test::Unit::TestCase +class I18nSimpleBackendApiTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::Pluralization end diff --git a/test/backend/cache_test.rb b/test/backend/cache_test.rb index 39df10d4..0f0e0285 100644 --- a/test/backend/cache_test.rb +++ b/test/backend/cache_test.rb @@ -6,7 +6,7 @@ $stderr.puts "Skipping cache tests using ActiveSupport" else -class I18nBackendCacheTest < Test::Unit::TestCase +class I18nBackendCacheTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::Cache end diff --git a/test/backend/cascade_test.rb b/test/backend/cascade_test.rb index c23f1674..e0bda10b 100644 --- a/test/backend/cascade_test.rb +++ b/test/backend/cascade_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nBackendCascadeTest < Test::Unit::TestCase +class I18nBackendCascadeTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::Cascade end diff --git a/test/backend/chain_test.rb b/test/backend/chain_test.rb index a3bb44b4..6b554137 100644 --- a/test/backend/chain_test.rb +++ b/test/backend/chain_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nBackendChainTest < Test::Unit::TestCase +class I18nBackendChainTest < I18n::TestCase def setup @first = backend(:en => { :foo => 'Foo', :formats => { :short => 'short' }, :plural_1 => { :one => '%{count}' }, :dates => {:a => "A"} diff --git a/test/backend/exceptions_test.rb b/test/backend/exceptions_test.rb index fc0f557c..5b5aef93 100644 --- a/test/backend/exceptions_test.rb +++ b/test/backend/exceptions_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nBackendExceptionsTest < Test::Unit::TestCase +class I18nBackendExceptionsTest < I18n::TestCase def setup I18n.backend = I18n::Backend::Simple.new end diff --git a/test/backend/fallbacks_test.rb b/test/backend/fallbacks_test.rb index 6ea09207..82f45af9 100644 --- a/test/backend/fallbacks_test.rb +++ b/test/backend/fallbacks_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nBackendFallbacksTranslateTest < Test::Unit::TestCase +class I18nBackendFallbacksTranslateTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::Fallbacks end @@ -75,7 +75,7 @@ def setup test "should ensure that default is not splitted on new line char" do assert_equal "Default \n Bar", I18n.t(:missing_bar, :default => "Default \n Bar") end - + test "should not raise error when enforce_available_locales is true, :'pt' is missing and default is a Symbol" do I18n.enforce_available_locales = true begin @@ -86,7 +86,7 @@ def setup end end -class I18nBackendFallbacksLocalizeTest < Test::Unit::TestCase +class I18nBackendFallbacksLocalizeTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::Fallbacks end @@ -118,7 +118,7 @@ def setup end end -class I18nBackendFallbacksWithChainTest < Test::Unit::TestCase +class I18nBackendFallbacksWithChainTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::Fallbacks end diff --git a/test/backend/interpolation_compiler_test.rb b/test/backend/interpolation_compiler_test.rb index 50170b2e..cffe28f9 100644 --- a/test/backend/interpolation_compiler_test.rb +++ b/test/backend/interpolation_compiler_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class InterpolationCompilerTest < Test::Unit::TestCase +class InterpolationCompilerTest < I18n::TestCase Compiler = I18n::Backend::InterpolationCompiler::Compiler def compile_and_interpolate(str, values = {}) @@ -95,7 +95,7 @@ def test_custom_missing_interpolation_argument_handler end end -class I18nBackendInterpolationCompilerTest < Test::Unit::TestCase +class I18nBackendInterpolationCompilerTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::InterpolationCompiler end diff --git a/test/backend/key_value_test.rb b/test/backend/key_value_test.rb index 74c6b7d1..b7fe8767 100644 --- a/test/backend/key_value_test.rb +++ b/test/backend/key_value_test.rb @@ -1,8 +1,8 @@ require 'test_helper' -I18n::Tests.setup_rufus_tokyo +I18n::TestCase.setup_rufus_tokyo -class I18nBackendKeyValueTest < Test::Unit::TestCase +class I18nBackendKeyValueTest < I18n::TestCase def setup_backend!(subtree=true) I18n.backend = I18n::Backend::KeyValue.new(Rufus::Tokyo::Cabinet.new('*'), subtree) store_translations(:en, :foo => { :bar => 'bar', :baz => 'baz' }) diff --git a/test/backend/metadata_test.rb b/test/backend/metadata_test.rb index 584c7f65..5ccb6462 100644 --- a/test/backend/metadata_test.rb +++ b/test/backend/metadata_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nBackendMetadataTest < Test::Unit::TestCase +class I18nBackendMetadataTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::Metadata end diff --git a/test/backend/pluralization_test.rb b/test/backend/pluralization_test.rb index 54fbba92..de318f1a 100644 --- a/test/backend/pluralization_test.rb +++ b/test/backend/pluralization_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nBackendPluralizationTest < Test::Unit::TestCase +class I18nBackendPluralizationTest < I18n::TestCase class Backend < I18n::Backend::Simple include I18n::Backend::Pluralization include I18n::Backend::Fallbacks diff --git a/test/backend/simple_test.rb b/test/backend/simple_test.rb index 4f37f48e..777a77c7 100644 --- a/test/backend/simple_test.rb +++ b/test/backend/simple_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nBackendSimpleTest < Test::Unit::TestCase +class I18nBackendSimpleTest < I18n::TestCase def setup I18n.backend = I18n::Backend::Simple.new I18n.load_path = [locales_dir + '/en.yml'] diff --git a/test/backend/transliterator_test.rb b/test/backend/transliterator_test.rb index a7f914e0..4012dce2 100644 --- a/test/backend/transliterator_test.rb +++ b/test/backend/transliterator_test.rb @@ -1,7 +1,7 @@ # encoding: utf-8 require 'test_helper' -class I18nBackendTransliterator < Test::Unit::TestCase +class I18nBackendTransliterator < I18n::TestCase def setup I18n.backend = I18n::Backend::Simple.new @proc = lambda { |n| n.upcase } diff --git a/test/core_ext/hash_test.rb b/test/core_ext/hash_test.rb index 25c57488..83093365 100644 --- a/test/core_ext/hash_test.rb +++ b/test/core_ext/hash_test.rb @@ -1,7 +1,7 @@ require 'test_helper' require 'i18n/core_ext/hash' -class I18nCoreExtHashInterpolationTest < Test::Unit::TestCase +class I18nCoreExtHashInterpolationTest < I18n::TestCase test "#deep_symbolize_keys" do hash = { 'foo' => { 'bar' => { 'baz' => 'bar' } } } expected = { :foo => { :bar => { :baz => 'bar' } } } diff --git a/test/core_ext/string/interpolate_test.rb b/test/core_ext/string/interpolate_test.rb index 993d454d..a1ed9c4c 100644 --- a/test/core_ext/string/interpolate_test.rb +++ b/test/core_ext/string/interpolate_test.rb @@ -5,7 +5,7 @@ # some tests taken from Masao's tests # http://github.com/mutoh/gettext/blob/edbbe1fa8238fa12c7f26f2418403015f0270e47/test/test_string.rb -class I18nCoreExtStringInterpolationTest < Test::Unit::TestCase +class I18nCoreExtStringInterpolationTest < I18n::TestCase test "String interpolates a single argument" do assert_equal "Masao", "%s" % "Masao" end diff --git a/test/gettext/api_test.rb b/test/gettext/api_test.rb index 947b5a23..ac4edaf0 100644 --- a/test/gettext/api_test.rb +++ b/test/gettext/api_test.rb @@ -4,7 +4,7 @@ include I18n::Gettext::Helpers -class I18nGettextApiTest < Test::Unit::TestCase +class I18nGettextApiTest < I18n::TestCase def setup I18n.locale = :en I18n.backend.store_translations :de, { diff --git a/test/gettext/backend_test.rb b/test/gettext/backend_test.rb index 39c64b35..ebba90b5 100644 --- a/test/gettext/backend_test.rb +++ b/test/gettext/backend_test.rb @@ -5,7 +5,7 @@ # apparently Ruby 1.9.1p129 has encoding problems with the gettext po parser unless RUBY_VERSION == '1.9.1' && RUBY_PATCHLEVEL <= 129 - class I18nGettextBackendTest < Test::Unit::TestCase + class I18nGettextBackendTest < I18n::TestCase include I18n::Gettext::Helpers class Backend < I18n::Backend::Simple diff --git a/test/i18n/exceptions_test.rb b/test/i18n/exceptions_test.rb index 2e5e1898..e633d7d9 100644 --- a/test/i18n/exceptions_test.rb +++ b/test/i18n/exceptions_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nExceptionsTest < Test::Unit::TestCase +class I18nExceptionsTest < I18n::TestCase def test_invalid_locale_stores_locale force_invalid_locale rescue I18n::ArgumentError => exception diff --git a/test/i18n/interpolate_test.rb b/test/i18n/interpolate_test.rb index 7041b322..74b6204d 100644 --- a/test/i18n/interpolate_test.rb +++ b/test/i18n/interpolate_test.rb @@ -4,7 +4,7 @@ # thanks to Masao's String extensions, some tests taken from Masao's tests # http://github.com/mutoh/gettext/blob/edbbe1fa8238fa12c7f26f2418403015f0270e47/test/test_string.rb -class I18nInterpolateTest < Test::Unit::TestCase +class I18nInterpolateTest < I18n::TestCase test "String interpolates a hash argument w/ named placeholders" do assert_equal "Masao Mutoh", I18n.interpolate("%{first} %{last}", :first => 'Masao', :last => 'Mutoh' ) end @@ -60,7 +60,7 @@ def test_sprintf_mix_unformatted_and_formatted_named_placeholders end end -class I18nMissingInterpolationCustomHandlerTest < Test::Unit::TestCase +class I18nMissingInterpolationCustomHandlerTest < I18n::TestCase def setup @old_handler = I18n.config.missing_interpolation_argument_handler I18n.config.missing_interpolation_argument_handler = lambda do |key, values, string| diff --git a/test/i18n/load_path_test.rb b/test/i18n/load_path_test.rb index 26d086ab..ebb023e7 100644 --- a/test/i18n/load_path_test.rb +++ b/test/i18n/load_path_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class I18nLoadPathTest < Test::Unit::TestCase +class I18nLoadPathTest < I18n::TestCase def setup I18n.locale = :en I18n.backend = I18n::Backend::Simple.new diff --git a/test/i18n_test.rb b/test/i18n_test.rb index fd7e5ea8..c64d595c 100644 --- a/test/i18n_test.rb +++ b/test/i18n_test.rb @@ -1,7 +1,7 @@ # encoding: utf-8 require 'test_helper' -class I18nTest < Test::Unit::TestCase +class I18nTest < I18n::TestCase def setup store_translations(:en, :currency => { :format => { :separator => '.', :delimiter => ',', } }) store_translations(:nl, :currency => { :format => { :separator => ',', :delimiter => '.', } }) diff --git a/test/locale/fallbacks_test.rb b/test/locale/fallbacks_test.rb index ca5e9427..b25f02d2 100644 --- a/test/locale/fallbacks_test.rb +++ b/test/locale/fallbacks_test.rb @@ -2,7 +2,7 @@ include I18n::Locale -class I18nFallbacksDefaultsTest < Test::Unit::TestCase +class I18nFallbacksDefaultsTest < I18n::TestCase def teardown I18n.default_locale = :en end @@ -26,7 +26,7 @@ def teardown end end -class I18nFallbacksComputationTest < Test::Unit::TestCase +class I18nFallbacksComputationTest < I18n::TestCase def setup @fallbacks = Fallbacks.new(:'en-US') end diff --git a/test/locale/tag/rfc4646_test.rb b/test/locale/tag/rfc4646_test.rb index 11180493..97fa6e45 100644 --- a/test/locale/tag/rfc4646_test.rb +++ b/test/locale/tag/rfc4646_test.rb @@ -1,7 +1,7 @@ # encoding: utf-8 require 'test_helper' -class I18nLocaleTagRfc4646ParserTest < Test::Unit::TestCase +class I18nLocaleTagRfc4646ParserTest < I18n::TestCase include I18n::Locale test "Rfc4646::Parser given a valid tag 'de' returns an array of subtags" do @@ -31,7 +31,7 @@ class I18nLocaleTagRfc4646ParserTest < Test::Unit::TestCase # Tag for the locale 'de-Latn-DE-Variant-a-ext-x-phonebk-i-klingon' -class I18nLocaleTagSubtagsTest < Test::Unit::TestCase +class I18nLocaleTagSubtagsTest < I18n::TestCase include I18n::Locale def setup @@ -78,7 +78,7 @@ def setup # Tag inheritance -class I18nLocaleTagSubtagsTest < Test::Unit::TestCase +class I18nLocaleTagSubtagsTest < I18n::TestCase test "#parent returns 'de-Latn-DE-variant-a-ext-x-phonebk' as the parent of 'de-Latn-DE-variant-a-ext-x-phonebk-i-klingon'" do tag = Tag::Rfc4646.new(*%w(de Latn DE variant a-ext x-phonebk i-klingon)) assert_equal 'de-Latn-DE-variant-a-ext-x-phonebk', tag.parent.to_s diff --git a/test/locale/tag/simple_test.rb b/test/locale/tag/simple_test.rb index ed2f76b4..002c63d2 100644 --- a/test/locale/tag/simple_test.rb +++ b/test/locale/tag/simple_test.rb @@ -1,7 +1,7 @@ # encoding: utf-8 require 'test_helper' -class I18nLocaleTagSimpleTest < Test::Unit::TestCase +class I18nLocaleTagSimpleTest < I18n::TestCase include I18n::Locale test "returns 'de' as the language subtag in lowercase" do diff --git a/test/test_helper.rb b/test/test_helper.rb index e23b5abb..53f34aad 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -17,8 +17,15 @@ def gem(gem_name, *version_requirements) require 'mocha/setup' require 'test_declarative' -class Test::Unit::TestCase +class I18n::TestCase < Test::Unit::TestCase + def self.setup_rufus_tokyo + require 'rufus/tokyo' + rescue LoadError => e + puts "can't use KeyValue backend because: #{e.message}" + end + def teardown + super I18n.locale = nil I18n.default_locale = :en I18n.load_path = [] @@ -27,6 +34,16 @@ def teardown I18n.enforce_available_locales = nil end + # Ignore Test::Unit::TestCase failing if the test case does not contain any + # test, otherwise it will blow up because of this base class. + # + # TODO: remove when test-unit is not used anymore. + def default_test + nil + end + + protected + def translations I18n.backend.instance_variable_get(:@translations) end @@ -39,11 +56,3 @@ def locales_dir File.dirname(__FILE__) + '/test_data/locales' end end - -module I18n::Tests - def self.setup_rufus_tokyo - require 'rufus/tokyo' - rescue LoadError => e - puts "can't use KeyValue backend because: #{e.message}" - end -end