aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/inflector_test.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-02-15 01:45:35 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-02-15 01:45:35 +0000
commitb1999be5a7efd67e2602c37ed898aa8433661863 (patch)
tree03bc833276075d802d0ce0ad261baed3d7232533 /activesupport/test/inflector_test.rb
parent88a3343ed57c01ca358da8473d15fc4d2b4a5bff (diff)
downloadrails-b1999be5a7efd67e2602c37ed898aa8433661863.tar.gz
rails-b1999be5a7efd67e2602c37ed898aa8433661863.tar.bz2
rails-b1999be5a7efd67e2602c37ed898aa8433661863.zip
A hopefully more successful attempt at the Routing branch merge
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@617 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test/inflector_test.rb')
-rw-r--r--activesupport/test/inflector_test.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/activesupport/test/inflector_test.rb b/activesupport/test/inflector_test.rb
index 4523430ebe..cdab0f9ed0 100644
--- a/activesupport/test/inflector_test.rb
+++ b/activesupport/test/inflector_test.rb
@@ -1,6 +1,13 @@
require 'test/unit'
require File.dirname(__FILE__) + '/../lib/inflector'
+module A
+ module B
+ class C
+ end
+ end
+end
+
class InflectorTest < Test::Unit::TestCase
SingularToPlural = {
"search" => "searches",
@@ -50,6 +57,12 @@ class InflectorTest < Test::Unit::TestCase
"SpecialGuest" => "special_guest",
"ApplicationController" => "application_controller"
}
+
+ CamelWithModuleToUnderscoreWithSlash = {
+ "Admin::Product" => "admin/product",
+ "Users::Commission::Department" => "users/commission/department",
+ "UsersSection::CommissionDepartment" => "users_section/commission_department",
+ }
ClassNameToForeignKeyWithUnderscore = {
"Person" => "person_id",
@@ -100,6 +113,18 @@ class InflectorTest < Test::Unit::TestCase
assert_equal "html_tidy_generator", Inflector.underscore("HTMLTidyGenerator")
end
+ def test_camelize_with_module
+ CamelWithModuleToUnderscoreWithSlash.each do |camel, underscore|
+ assert_equal(camel, Inflector.camelize(underscore))
+ end
+ end
+
+ def test_underscore_with_slashes
+ CamelWithModuleToUnderscoreWithSlash.each do |camel, underscore|
+ assert_equal(underscore, Inflector.underscore(camel))
+ end
+ end
+
def test_demodulize
assert_equal "Account", Inflector.demodulize("MyApplication::Billing::Account")
end
@@ -131,4 +156,10 @@ class InflectorTest < Test::Unit::TestCase
assert_equal(human, Inflector.humanize(underscore))
end
end
+
+ def test_constantize
+ assert_equal A::B::C, Inflector.constantize("A::B::C")
+ assert_equal InflectorTest, Inflector.constantize("InflectorTest")
+ assert_raises(NameError) { Inflector.constantize("UnknownClass") }
+ end
end \ No newline at end of file