aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-06-08 04:05:35 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-06-08 04:05:35 +0000
commitb195ed61c8419eb39df122e48d196779abcee81f (patch)
treeb23b4dcfc452263c1fecd18c8613c8f9fb0bf689 /actionpack/test/template
parent34b94de8b87d7c32a1fdba72eb1f02296f31cffe (diff)
downloadrails-b195ed61c8419eb39df122e48d196779abcee81f.tar.gz
rails-b195ed61c8419eb39df122e48d196779abcee81f.tar.bz2
rails-b195ed61c8419eb39df122e48d196779abcee81f.zip
Improve Text Helper test coverage. Closes #7274.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6968 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/template')
-rw-r--r--actionpack/test/template/text_helper_test.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/actionpack/test/template/text_helper_test.rb b/actionpack/test/template/text_helper_test.rb
index 61afbb5136..1f5b90e811 100644
--- a/actionpack/test/template/text_helper_test.rb
+++ b/actionpack/test/template/text_helper_test.rb
@@ -31,6 +31,11 @@ class TextHelperTest < Test::Unit::TestCase
assert_equal "Hello Wor...", truncate("Hello World!!", 12)
end
+ def test_truncate_should_use_default_length_of_30
+ str = "This is a string that will go longer then the default truncate length of 30"
+ assert_equal str[0...27] + "...", truncate(str)
+ end
+
def test_truncate_multibyte
with_kcode 'none' do
assert_equal "\354\225\210\353\205\225\355...", truncate("\354\225\210\353\205\225\355\225\230\354\204\270\354\232\224", 10)
@@ -124,6 +129,19 @@ class TextHelperTest < Test::Unit::TestCase
assert_equal("1.25 counts", pluralize('1.25', "count"))
assert_equal("2 counters", pluralize(2, "count", "counters"))
assert_equal("0 counters", pluralize(nil, "count", "counters"))
+ assert_equal("2 people", pluralize(2, "person"))
+ assert_equal("10 buffaloes", pluralize(10, "buffalo"))
+ end
+
+ uses_mocha("should_just_add_s_for_pluralize_without_inflector_loaded") do
+ def test_should_just_add_s_for_pluralize_without_inflector_loaded
+ Object.expects(:const_defined?).with("Inflector").times(4).returns(false)
+ assert_equal("1 count", pluralize(1, "count"))
+ assert_equal("2 persons", pluralize(2, "person"))
+ assert_equal("2 personss", pluralize("2", "persons"))
+ assert_equal("2 counts", pluralize(2, "count"))
+ assert_equal("10 buffalos", pluralize(10, "buffalo"))
+ end
end
def test_auto_link_parsing