From 11b6f9e06ae48dcdab30dc09634a276ae2707889 Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Sat, 31 Dec 2016 09:28:52 +0530 Subject: [PATCH] Make the tests for uncountability of ascii and non-ascii words uniform --- activesupport/test/inflector_test.rb | 32 ++++++++++++++++++---------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/activesupport/test/inflector_test.rb b/activesupport/test/inflector_test.rb index b054e41a79..8d39303f9b 100644 --- a/activesupport/test/inflector_test.rb +++ b/activesupport/test/inflector_test.rb @@ -31,11 +31,29 @@ class InflectorTest < ActiveSupport::TestCase assert_equal "", ActiveSupport::Inflector.pluralize("") end - def test_pluralize_for_words_with_non_ascii_characters + test "uncountability of ascii word" do + word = "HTTP" ActiveSupport::Inflector.inflections do |inflect| - inflect.uncountable "猫" + inflect.uncountable word end - assert_equal "猫", ActiveSupport::Inflector.pluralize("猫") + + assert_equal word, ActiveSupport::Inflector.pluralize(word) + assert_equal word, ActiveSupport::Inflector.singularize(word) + assert_equal ActiveSupport::Inflector.pluralize(word), ActiveSupport::Inflector.singularize(word) + + ActiveSupport::Inflector.inflections.uncountables.pop + end + + test "uncountability of non-ascii word" do + word = "猫" + ActiveSupport::Inflector.inflections do |inflect| + inflect.uncountable word + end + + assert_equal word, ActiveSupport::Inflector.pluralize(word) + assert_equal word, ActiveSupport::Inflector.singularize(word) + assert_equal ActiveSupport::Inflector.pluralize(word), ActiveSupport::Inflector.singularize(word) + ActiveSupport::Inflector.inflections.uncountables.pop end @@ -515,12 +533,4 @@ class InflectorTest < ActiveSupport::TestCase end end end - - def test_inflections_with_uncountable_words - ActiveSupport::Inflector.inflections do |inflect| - inflect.uncountable "HTTP" - end - - assert_equal "HTTP", ActiveSupport::Inflector.pluralize("HTTP") - end end