$:.unshift File.join(File.dirname(__FILE__),'..','lib') require 'test/unit' require 'truncateHTML' class TruncateHTMLTest < Test::Unit::TestCase def test_truncate_html_ignores_doc_type msg = <<-DOCMSG Take this bottle and go fetch me some water please. Another of those mobiles is going bad. DOCMSG assert_equal("Take this bottle and go fetch me some...", TruncateHTML.truncate(msg, :max_length => 40)) end def test_truncate_html_with_body_node msg = <<-MSG Dear Ramana,
Satyaram is currently setting up his account. The fourth estate magazine is a big time hit of all time
MSG assert_equal("Dear Ramana,
Satyaram is currently...", TruncateHTML.truncate(msg, :max_length => 40, :words => true)) end def test_truncate_html_plain_text text = "this is some exmaple test" assert_equal("this is...", TruncateHTML.truncate(text, :max_length => 10)) end def test_truncate_html_ordinary_nodes text = "

this is some exmaple

test

" assert_equal("

this is

...", TruncateHTML.truncate(text, :max_length => 10)) end def test_truncate_html_with_html_with_multiple_bodies msg = <<-MSG Dear Ramana,
Satyaram is currently setting up his account. The fourth estate magazine is a big time hit of all time
Dear Ramana,
Satyaram is currently setting up his account. The fourth estate magazine is a big time hit of all time
MSG assert_equal("Dear Ramana,
Satyaram is currently set...", TruncateHTML.truncate(msg)) end end