Permalink
Browse files

easier way to reset localization. useful only in tests really i guess.

  • Loading branch information...
1 parent 591f22a commit f8a3ea3e1b35a694265ae37fd085d2fc697ac258 @rsl committed Mar 18, 2013
Showing with 10 additions and 14 deletions.
  1. +4 −0 lib/stringex/localization.rb
  2. +2 −5 test/localization_test.rb
  3. +4 −9 test/string_extensions_test.rb
@@ -76,6 +76,10 @@ def with_default_locale(&block)
with_locale default_locale, &block
end
+ def reset!
+ @backend = @translations = @locale = @default_locale = nil
+ end
+
private
def initial_translation(scope, key, locale)
@@ -1,11 +1,8 @@
require "test_helper"
class LocalizationTest < Test::Unit::TestCase
- def teardown
- Stringex::Localization.translations = nil
- Stringex::Localization.backend = nil
- Stringex::Localization.default_locale = :en
- Stringex::Localization.locale = :en
+ def setup
+ Stringex::Localization.reset!
end
def test_stores_translations
@@ -7,6 +7,10 @@
end
class StringExtensionsTest < Test::Unit::TestCase
+ def setup
+ Stringex::Localization.reset!
+ end
+
def test_to_html
require "rubygems"
require "RedCloth"
@@ -208,9 +212,6 @@ def test_localized_vulgar_fractions_conversion
}.each do |entitied, plain|
assert_equal plain, entitied.convert_vulgar_fractions
end
-
- ensure
- Stringex::Localization.translations = nil
end
def test_convert_miscellaneous_html_entities
@@ -242,9 +243,6 @@ def test_localized_html_entities_conversion
}.each do |entitied, plain|
assert_equal plain, entitied.convert_miscellaneous_html_entities
end
-
- ensure
- Stringex::Localization.translations = nil
end
def test_convert_smart_punctuation
@@ -290,9 +288,6 @@ def test_localized_character_conversions
}.each do |misc, plain|
assert_equal plain, misc.convert_miscellaneous_characters
end
-
- ensure
- Stringex::Localization.translations = nil
end
def test_replace_whitespace

0 comments on commit f8a3ea3

Please sign in to comment.