aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/html-scanner/text_node_test.rb
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2007-02-04 20:04:40 +0000
committerRick Olson <technoweenie@gmail.com>2007-02-04 20:04:40 +0000
commit19fbb31464da45ac0935b3db193305f18e245ba9 (patch)
tree57543807ad63d7deb7cf5deb037fc64aed710492 /actionpack/test/controller/html-scanner/text_node_test.rb
parent4790228bc437c6c882bb2171a429979b37f52618 (diff)
downloadrails-19fbb31464da45ac0935b3db193305f18e245ba9.tar.gz
rails-19fbb31464da45ac0935b3db193305f18e245ba9.tar.bz2
rails-19fbb31464da45ac0935b3db193305f18e245ba9.zip
Add much-needed html-scanner tests. Fixed CDATA parsing bug. [Rick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6117 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller/html-scanner/text_node_test.rb')
-rw-r--r--actionpack/test/controller/html-scanner/text_node_test.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/actionpack/test/controller/html-scanner/text_node_test.rb b/actionpack/test/controller/html-scanner/text_node_test.rb
new file mode 100644
index 0000000000..9853701fda
--- /dev/null
+++ b/actionpack/test/controller/html-scanner/text_node_test.rb
@@ -0,0 +1,51 @@
+require File.dirname(__FILE__) + '/../../abstract_unit'
+require 'test/unit'
+
+class TextNodeTest < Test::Unit::TestCase
+ def setup
+ @node = HTML::Text.new(nil, 0, 0, "hello, howdy, aloha, annyeong")
+ end
+
+ def test_to_s
+ assert_equal "hello, howdy, aloha, annyeong", @node.to_s
+ end
+
+ def test_find_string
+ assert_equal @node, @node.find("hello, howdy, aloha, annyeong")
+ assert_equal false, @node.find("bogus")
+ end
+
+ def test_find_regexp
+ assert_equal @node, @node.find(/an+y/)
+ assert_nil @node.find(/b/)
+ end
+
+ def test_find_hash
+ assert_equal @node, @node.find(:content => /howdy/)
+ assert_nil @node.find(:content => /^howdy$/)
+ assert_equal false, @node.find(:content => "howdy")
+ end
+
+ def test_find_other
+ assert_nil @node.find(:hello)
+ end
+
+ def test_match_string
+ assert @node.match("hello, howdy, aloha, annyeong")
+ assert_equal false, @node.match("bogus")
+ end
+
+ def test_match_regexp
+ assert_not_nil @node, @node.match(/an+y/)
+ assert_nil @node.match(/b/)
+ end
+
+ def test_match_hash
+ assert_not_nil @node, @node.match(:content => "howdy")
+ assert_nil @node.match(:content => /^howdy$/)
+ end
+
+ def test_match_other
+ assert_nil @node.match(:hello)
+ end
+end \ No newline at end of file