aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorMarcel Molina <marcel@vernix.org>2005-10-19 20:20:11 +0000
committerMarcel Molina <marcel@vernix.org>2005-10-19 20:20:11 +0000
commitb23c72fd4220b3d282ec07f63b0571fe5dfc4f0e (patch)
tree7dbe954938956592ae79a164863457601f2cb8cb /activesupport/test
parent4da2d6c1edee8b31896a206a3ed18e7af605501d (diff)
downloadrails-b23c72fd4220b3d282ec07f63b0571fe5dfc4f0e.tar.gz
rails-b23c72fd4220b3d282ec07f63b0571fe5dfc4f0e.tar.bz2
rails-b23c72fd4220b3d282ec07f63b0571fe5dfc4f0e.zip
Add title case method to String to do, e.g., 'action_web_service'.titlecase # => 'Action Web Service'.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2690 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/inflector_test.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/activesupport/test/inflector_test.rb b/activesupport/test/inflector_test.rb
index 0f398df8ff..cbf8250823 100644
--- a/activesupport/test/inflector_test.rb
+++ b/activesupport/test/inflector_test.rb
@@ -146,6 +146,16 @@ class InflectorTest < Test::Unit::TestCase
"underground" => "Underground"
}
+ MixtureToTitleCase = {
+ 'active_record' => 'Active Record',
+ 'ActiveRecord' => 'Active Record',
+ 'action web service' => 'Action Web Service',
+ 'Action Web Service' => 'Action Web Service',
+ 'Action web service' => 'Action Web Service',
+ 'actionwebservice' => 'Actionwebservice',
+ 'Actionwebservice' => 'Actionwebservice'
+ }
+
OrdinalNumbers = {
"0" => "0th",
"1" => "1st",
@@ -196,6 +206,12 @@ class InflectorTest < Test::Unit::TestCase
end
end
+ MixtureToTitleCase.each do |before, title_cased|
+ define_method 'test_titlecase' do
+ assert_equal(title_cased, Inflector.titleize(before))
+ end
+ end
+
def test_camelize
CamelToUnderscore.each do |camel, underscore|
assert_equal(camel, Inflector.camelize(underscore))