require File.dirname(__FILE__) + '/../../abstract_unit' require 'test/unit' class DocumentTest < Test::Unit::TestCase def test_handle_doctype doc = nil assert_nothing_raised do doc = HTML::Document.new <<-HTML.strip HTML end assert_equal 3, doc.root.children.length assert_equal %{}, doc.root.children[0].content assert_match %r{\s+}m, doc.root.children[1].content assert_equal "html", doc.root.children[2].name end def test_find_img doc = HTML::Document.new <<-HTML.strip
HTML assert doc.find(:tag=>"img", :attributes=>{"src"=>"hello.gif"}) end def test_find_all doc = HTML::Document.new <<-HTML.stripsomething
here is more
Some text
HTML assert doc.find(:content => "Some text") assert doc.find(:tag => "p", :child => { :content => "Some text" }) assert doc.find(:tag => "p", :child => "Some text") assert doc.find(:tag => "p", :content => "Some text") end def test_parse_xml assert_nothing_raised { HTML::Document.new("this document has <br> for a title
HTML assert_nil doc.find(:tag => "title", :descendant => { :tag => "br" }) assert doc.find(:tag => "title", :child => "