Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit f8a3ea3e1b35a694265ae37fd085d2fc697ac258 1 parent 591f22a
@rsl authored
View
4 lib/stringex/localization.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)
View
7 test/localization_test.rb
@@ -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
View
13 test/string_extensions_test.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.