Skip to content

Commit

Permalink
Ensure that uncountable are removed after test
Browse files Browse the repository at this point in the history
  • Loading branch information
drogus committed Dec 22, 2010
1 parent cad4f00 commit 725817e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions activesupport/test/inflector_test.rb
Expand Up @@ -21,21 +21,21 @@ def test_pluralize_plurals
def test_pluralize_empty_string
assert_equal "", ActiveSupport::Inflector.pluralize("")
end

ActiveSupport::Inflector.inflections.uncountable.each do |word|
define_method "test_uncountability_of_#{word}" do
assert_equal word, ActiveSupport::Inflector.singularize(word)
assert_equal word, ActiveSupport::Inflector.pluralize(word)
assert_equal ActiveSupport::Inflector.pluralize(word), ActiveSupport::Inflector.singularize(word)
end
end

def test_uncountable_word_is_not_greedy
uncountable_word = "ors"
countable_word = "sponsor"

cached_uncountables = ActiveSupport::Inflector.inflections.uncountables

ActiveSupport::Inflector.inflections.uncountable << uncountable_word

assert_equal uncountable_word, ActiveSupport::Inflector.singularize(uncountable_word)
Expand All @@ -45,7 +45,8 @@ def test_uncountable_word_is_not_greedy
assert_equal "sponsor", ActiveSupport::Inflector.singularize(countable_word)
assert_equal "sponsors", ActiveSupport::Inflector.pluralize(countable_word)
assert_equal "sponsor", ActiveSupport::Inflector.singularize(ActiveSupport::Inflector.pluralize(countable_word))


ensure
ActiveSupport::Inflector.inflections.instance_variable_set :@uncountables, cached_uncountables
end

Expand Down

0 comments on commit 725817e

Please sign in to comment.