Methods
- T
-
- test_find_all,
- test_find_empty_tag,
- test_find_img,
- test_find_with_text,
- test_handle_doctype,
- test_invalid_document_raises_exception_when_strict,
- test_parse_cdata,
- test_parse_document,
- test_parse_invalid_document,
- test_parse_xml,
- test_tag_nesting_nothing_to_s,
- test_tag_nesting_space_to_s,
- test_tag_nesting_tag_to_s,
- test_tag_nesting_text_to_s
Instance Public methods
test_find_all()
Link
# File actionpack/test/template/html-scanner/document_test.rb, line 30 def test_find_all doc = HTML::Document.new " <html> <body> <p class="test"><img src="hello.gif"></p> <div class="foo"> <p class="test">something</p> <p>here is <em class="test">more</em></p> </div> </body> </html> ".strip all = doc.find_all :attributes => { :class => "test" } assert_equal 3, all.length assert_equal [ "p", "p", "em" ], all.map { |n| n.name } end
test_find_empty_tag()
Link
# File actionpack/test/template/html-scanner/document_test.rb, line 115 def test_find_empty_tag doc = HTML::Document.new("<div id='map'></div>") assert_nil doc.find(:tag => "div", :attributes => { :id => "map" }, :content => /./) assert doc.find(:tag => "div", :attributes => { :id => "map" }, :content => /\A\Z/) assert doc.find(:tag => "div", :attributes => { :id => "map" }, :content => /^$/) assert doc.find(:tag => "div", :attributes => { :id => "map" }, :content => "") assert doc.find(:tag => "div", :attributes => { :id => "map" }, :content => nil) end
test_find_img()
Link
test_find_with_text()
Link
# File actionpack/test/template/html-scanner/document_test.rb, line 47 def test_find_with_text doc = HTML::Document.new " <html> <body> <p>Some text</p> </body> </html> ".strip 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
test_handle_doctype()
Link
# File actionpack/test/template/html-scanner/document_test.rb, line 4 def test_handle_doctype doc = nil assert_nothing_raised do doc = HTML::Document.new " <!DOCTYPE "blah" "blah" "blah"> <html> </html> ".strip end assert_equal 3, doc.root.children.length assert_equal %Q{<!DOCTYPE "blah" "blah" "blah">}, doc.root.children[0].content assert_match %r{\s+}m, doc.root.children[1].content assert_equal "html", doc.root.children[2].name end
test_invalid_document_raises_exception_when_strict()
Link
# File actionpack/test/template/html-scanner/document_test.rb, line 136 def test_invalid_document_raises_exception_when_strict assert_raise RuntimeError do HTML::Document.new("<html> <table> <tr> <td style=\"color: #FFFFFF; height: 17px; onclick=\"window.location.href='http://www.rmeinc.com/about_rme.aspx'\" style=\"cursor:pointer; height: 17px;\"; nowrap onclick=\"window.location.href='http://www.rmeinc.com/about_rme.aspx'\" onmouseout=\"this.bgColor='#0066cc'; this.style.color='#FFFFFF'\" onmouseover=\"this.bgColor='#ffffff'; this.style.color='#0033cc'\">About Us</td> </tr> </table> </html>", true) end end
test_parse_cdata()
Link
# File actionpack/test/template/html-scanner/document_test.rb, line 97 def test_parse_cdata doc = HTML::Document.new("<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title><![CDATA[<br>]]></title> </head> <body> <p>this document has <br> for a title</p> </body> </html> ") assert_nil doc.find(:tag => "title", :descendant => { :tag => "br" }) assert doc.find(:tag => "title", :child => "<br>") end
test_parse_document()
Link
test_parse_invalid_document()
Link
# File actionpack/test/template/html-scanner/document_test.rb, line 124 def test_parse_invalid_document assert_nothing_raised do HTML::Document.new("<html> <table> <tr> <td style=\"color: #FFFFFF; height: 17px; onclick=\"window.location.href='http://www.rmeinc.com/about_rme.aspx'\" style=\"cursor:pointer; height: 17px;\"; nowrap onclick=\"window.location.href='http://www.rmeinc.com/about_rme.aspx'\" onmouseout=\"this.bgColor='#0066cc'; this.style.color='#FFFFFF'\" onmouseover=\"this.bgColor='#ffffff'; this.style.color='#0033cc'\">About Us</td> </tr> </table> </html>") end end
test_parse_xml()
Link
test_tag_nesting_nothing_to_s()
Link
test_tag_nesting_space_to_s()
Link
test_tag_nesting_tag_to_s()
Link