Permalink
Browse files

Improve Text Helper test coverage. Closes #7274.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6968 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 34b94de commit b195ed61c8419eb39df122e48d196779abcee81f @jeremy jeremy committed Jun 8, 2007
Showing with 21 additions and 1 deletion.
  1. +3 −1 actionpack/CHANGELOG
  2. +18 −0 actionpack/test/template/text_helper_test.rb
View
@@ -1,5 +1,7 @@
*SVN*
+* Improve Text Helper test coverage. #7274 [Rob Sanheim, Josh Peek]
+
* Improve Action View test coverage. #7241, #7243, #7244 [Rich Collins]
* Resources: url_for([parent, child]) generates /parents/1/children/2 for the nested resource. Likewise with the other simply helpful methods like form_for and link_to. #6432 [mhw, Jonathan Vaught, lotswholetime]
@@ -562,7 +564,7 @@ superclass' view_paths. [Rick]
* Update Routing to complain when :controller is not specified by a route. Closes #6669. [Nicholas Seckar]
-* Ensure render_to_string cleans up after itself when an exception is raised. #6658 [rsanheim]
+* Ensure render_to_string cleans up after itself when an exception is raised. #6658 [Rob Sanheim]
* Extract template_changed_since? from compile_template? so plugins may override its behavior for non-file-based templates. #6651 [Jeff Barczewski]
@@ -31,6 +31,11 @@ def test_truncate
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 @@ def test_pluralization
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

0 comments on commit b195ed6

Please sign in to comment.