From b0ed5057e01b78f2f7e0e078c0534647b425c290 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 28 Jan 2007 15:52:45 +0000 Subject: Full test coverage for Inflector. Closes #7228. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6075 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/test/core_ext/string_ext_test.rb | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'activesupport/test/core_ext/string_ext_test.rb') diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb index 7eff505a22..cd2d12c3b1 100644 --- a/activesupport/test/core_ext/string_ext_test.rb +++ b/activesupport/test/core_ext/string_ext_test.rb @@ -16,6 +16,12 @@ class StringInflectionsTest < Test::Unit::TestCase end end + def test_titleize + InflectorTest::MixtureToTitleCase.each do |before, titleized| + assert_equal(titleized, before.titleize) + end + end + def test_camelize InflectorTest::CamelToUnderscore.each do |camel, underscore| assert_equal(camel, underscore.camelize) @@ -31,8 +37,14 @@ class StringInflectionsTest < Test::Unit::TestCase assert_equal "html_tidy_generator", "HTMLTidyGenerator".underscore end + def test_underscore_to_lower_camel + InflectorTest::UnderscoreToLowerCamel.each do |underscored, lower_camel| + assert_equal(lower_camel, underscored.camelize(:lower)) + end + end + def test_demodulize - assert_equal "Account", Inflector.demodulize("MyApplication::Billing::Account") + assert_equal "Account", "MyApplication::Billing::Account".demodulize end def test_foreign_key @@ -57,6 +69,12 @@ class StringInflectionsTest < Test::Unit::TestCase end end + def test_humanize + InflectorTest::UnderscoreToHuman.each do |underscore, human| + assert_equal(human, underscore.humanize) + end + end + def test_string_to_time assert_equal Time.utc(2005, 2, 27, 23, 50), "2005-02-27 23:50".to_time assert_equal Time.local(2005, 2, 27, 23, 50), "2005-02-27 23:50".to_time(:local) -- cgit v1.2.3