aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/inflector_test.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-07-17 10:02:23 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-07-17 10:02:23 +0000
commit33cf8f162e1ea2c10e6ba253b333f256802c3250 (patch)
tree2c4fca502c8afe64ead7fa9bc7849dab4f1fdc0d /activesupport/test/inflector_test.rb
parent80cfa76f7de298b5eb3e2b971766c676e9e147b1 (diff)
downloadrails-33cf8f162e1ea2c10e6ba253b333f256802c3250.tar.gz
rails-33cf8f162e1ea2c10e6ba253b333f256802c3250.tar.bz2
rails-33cf8f162e1ea2c10e6ba253b333f256802c3250.zip
Added Fixnum#ordinalize to turn 1.ordinalize to "1st", 3.ordinalize to "3rd", and 10.ordinalize to "10th" and so on #1724 [paul@cnt.org]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1852 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test/inflector_test.rb')
-rw-r--r--activesupport/test/inflector_test.rb39
1 files changed, 38 insertions, 1 deletions
diff --git a/activesupport/test/inflector_test.rb b/activesupport/test/inflector_test.rb
index 533879cbc2..2d69431cd4 100644
--- a/activesupport/test/inflector_test.rb
+++ b/activesupport/test/inflector_test.rb
@@ -131,6 +131,37 @@ class InflectorTest < Test::Unit::TestCase
"underground" => "Underground"
}
+ OrdinalNumbers = {
+ "0" => "0th",
+ "1" => "1st",
+ "2" => "2nd",
+ "3" => "3rd",
+ "4" => "4th",
+ "5" => "5th",
+ "6" => "6th",
+ "7" => "7th",
+ "8" => "8th",
+ "9" => "9th",
+ "10" => "10th",
+ "11" => "11th",
+ "12" => "12th",
+ "13" => "13th",
+ "14" => "14th",
+ "20" => "20th",
+ "21" => "21st",
+ "22" => "22nd",
+ "23" => "23rd",
+ "24" => "24th",
+ "100" => "100th",
+ "101" => "101st",
+ "102" => "102nd",
+ "103" => "103rd",
+ "104" => "104th",
+ "110" => "110th",
+ "1000" => "1000th",
+ "1001" => "1001st"
+ }
+
def test_pluralize_plurals
assert_equal "plurals", Inflector.pluralize("plurals")
assert_equal "Plurals", Inflector.pluralize("Plurals")
@@ -214,4 +245,10 @@ class InflectorTest < Test::Unit::TestCase
assert_equal InflectorTest, Inflector.constantize("InflectorTest")
assert_raises(NameError) { Inflector.constantize("UnknownClass") }
end
-end \ No newline at end of file
+
+ def test_ordinal
+ OrdinalNumbers.each do |number, ordinalized|
+ assert_equal(ordinalized, Inflector.ordinalize(number))
+ end
+ end
+end