aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template/text_helper_test.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-03-30 01:19:01 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-03-30 01:19:01 +0000
commit67d5a1abedaae4c2ccc5057bb6780708f04b5f10 (patch)
tree78f884ea378f691f8827b314540324df6f15a86e /actionpack/test/template/text_helper_test.rb
parent29d63a04acabf398aa161857b603d99a2bf8e51b (diff)
downloadrails-67d5a1abedaae4c2ccc5057bb6780708f04b5f10.tar.gz
rails-67d5a1abedaae4c2ccc5057bb6780708f04b5f10.tar.bz2
rails-67d5a1abedaae4c2ccc5057bb6780708f04b5f10.zip
Highlight helper highlights one or many terms in a single pass.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6493 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/template/text_helper_test.rb')
-rw-r--r--actionpack/test/template/text_helper_test.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/actionpack/test/template/text_helper_test.rb b/actionpack/test/template/text_helper_test.rb
index 2f11547db5..61afbb5136 100644
--- a/actionpack/test/template/text_helper_test.rb
+++ b/actionpack/test/template/text_helper_test.rb
@@ -65,6 +65,8 @@ class TextHelperTest < Test::Unit::TestCase
"This text is not changed because we supplied an empty phrase",
highlight("This text is not changed because we supplied an empty phrase", nil)
)
+
+ assert_equal ' ', highlight(' ', 'blank text is returned verbatim')
end
def test_highlighter_with_regexp
@@ -84,6 +86,10 @@ class TextHelperTest < Test::Unit::TestCase
)
end
+ def test_highlighting_multiple_phrases_in_one_pass
+ assert_equal %(<em>wow</em> <em>em</em>), highlight('wow em', %w(wow em), '<em>\1</em>')
+ end
+
def test_excerpt
assert_equal("...is a beautiful morni...", excerpt("This is a beautiful morning", "beautiful", 5))
assert_equal("This is a...", excerpt("This is a beautiful morning", "this", 5))