nokogiri 1.3.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of nokogiri might be problematic. Click here for more details.
- data/.autotest +27 -0
- data/CHANGELOG.ja.rdoc +233 -0
- data/CHANGELOG.rdoc +222 -0
- data/Manifest.txt +247 -0
- data/README.ja.rdoc +103 -0
- data/README.rdoc +117 -0
- data/Rakefile +205 -0
- data/bin/nokogiri +47 -0
- data/ext/nokogiri/extconf.rb +89 -0
- data/ext/nokogiri/html_document.c +183 -0
- data/ext/nokogiri/html_document.h +10 -0
- data/ext/nokogiri/html_element_description.c +272 -0
- data/ext/nokogiri/html_element_description.h +10 -0
- data/ext/nokogiri/html_entity_lookup.c +30 -0
- data/ext/nokogiri/html_entity_lookup.h +8 -0
- data/ext/nokogiri/html_sax_parser.c +57 -0
- data/ext/nokogiri/html_sax_parser.h +11 -0
- data/ext/nokogiri/iconv.dll +0 -0
- data/ext/nokogiri/libexslt.dll +0 -0
- data/ext/nokogiri/libxml2.dll +0 -0
- data/ext/nokogiri/libxslt.dll +0 -0
- data/ext/nokogiri/nokogiri.c +81 -0
- data/ext/nokogiri/nokogiri.h +149 -0
- data/ext/nokogiri/xml_attr.c +92 -0
- data/ext/nokogiri/xml_attr.h +9 -0
- data/ext/nokogiri/xml_cdata.c +53 -0
- data/ext/nokogiri/xml_cdata.h +9 -0
- data/ext/nokogiri/xml_comment.c +51 -0
- data/ext/nokogiri/xml_comment.h +9 -0
- data/ext/nokogiri/xml_document.c +308 -0
- data/ext/nokogiri/xml_document.h +21 -0
- data/ext/nokogiri/xml_document_fragment.c +48 -0
- data/ext/nokogiri/xml_document_fragment.h +10 -0
- data/ext/nokogiri/xml_dtd.c +102 -0
- data/ext/nokogiri/xml_dtd.h +8 -0
- data/ext/nokogiri/xml_entity_reference.c +50 -0
- data/ext/nokogiri/xml_entity_reference.h +9 -0
- data/ext/nokogiri/xml_io.c +24 -0
- data/ext/nokogiri/xml_io.h +10 -0
- data/ext/nokogiri/xml_namespace.c +69 -0
- data/ext/nokogiri/xml_namespace.h +12 -0
- data/ext/nokogiri/xml_node.c +928 -0
- data/ext/nokogiri/xml_node.h +14 -0
- data/ext/nokogiri/xml_node_set.c +386 -0
- data/ext/nokogiri/xml_node_set.h +9 -0
- data/ext/nokogiri/xml_processing_instruction.c +54 -0
- data/ext/nokogiri/xml_processing_instruction.h +9 -0
- data/ext/nokogiri/xml_reader.c +572 -0
- data/ext/nokogiri/xml_reader.h +10 -0
- data/ext/nokogiri/xml_relax_ng.c +106 -0
- data/ext/nokogiri/xml_relax_ng.h +9 -0
- data/ext/nokogiri/xml_sax_parser.c +336 -0
- data/ext/nokogiri/xml_sax_parser.h +10 -0
- data/ext/nokogiri/xml_sax_push_parser.c +86 -0
- data/ext/nokogiri/xml_sax_push_parser.h +9 -0
- data/ext/nokogiri/xml_schema.c +107 -0
- data/ext/nokogiri/xml_schema.h +9 -0
- data/ext/nokogiri/xml_syntax_error.c +203 -0
- data/ext/nokogiri/xml_syntax_error.h +12 -0
- data/ext/nokogiri/xml_text.c +47 -0
- data/ext/nokogiri/xml_text.h +9 -0
- data/ext/nokogiri/xml_xpath.c +53 -0
- data/ext/nokogiri/xml_xpath.h +11 -0
- data/ext/nokogiri/xml_xpath_context.c +252 -0
- data/ext/nokogiri/xml_xpath_context.h +9 -0
- data/ext/nokogiri/xslt_stylesheet.c +131 -0
- data/ext/nokogiri/xslt_stylesheet.h +9 -0
- data/ext/nokogiri/zlib1.dll +0 -0
- data/lib/action-nokogiri.rb +36 -0
- data/lib/nokogiri.rb +110 -0
- data/lib/nokogiri/1.8/nokogiri.so +0 -0
- data/lib/nokogiri/1.9/nokogiri.so +0 -0
- data/lib/nokogiri/css.rb +25 -0
- data/lib/nokogiri/css/generated_parser.rb +748 -0
- data/lib/nokogiri/css/generated_tokenizer.rb +144 -0
- data/lib/nokogiri/css/node.rb +107 -0
- data/lib/nokogiri/css/parser.rb +82 -0
- data/lib/nokogiri/css/parser.y +227 -0
- data/lib/nokogiri/css/syntax_error.rb +7 -0
- data/lib/nokogiri/css/tokenizer.rb +11 -0
- data/lib/nokogiri/css/tokenizer.rex +54 -0
- data/lib/nokogiri/css/xpath_visitor.rb +172 -0
- data/lib/nokogiri/decorators.rb +2 -0
- data/lib/nokogiri/decorators/hpricot.rb +3 -0
- data/lib/nokogiri/decorators/hpricot/node.rb +56 -0
- data/lib/nokogiri/decorators/hpricot/node_set.rb +54 -0
- data/lib/nokogiri/decorators/hpricot/xpath_visitor.rb +30 -0
- data/lib/nokogiri/decorators/slop.rb +33 -0
- data/lib/nokogiri/ffi/html/document.rb +37 -0
- data/lib/nokogiri/ffi/html/element_description.rb +85 -0
- data/lib/nokogiri/ffi/html/entity_lookup.rb +16 -0
- data/lib/nokogiri/ffi/html/sax/parser.rb +21 -0
- data/lib/nokogiri/ffi/io_callbacks.rb +32 -0
- data/lib/nokogiri/ffi/libxml.rb +314 -0
- data/lib/nokogiri/ffi/structs/common_node.rb +26 -0
- data/lib/nokogiri/ffi/structs/html_elem_desc.rb +24 -0
- data/lib/nokogiri/ffi/structs/html_entity_desc.rb +13 -0
- data/lib/nokogiri/ffi/structs/xml_alloc.rb +16 -0
- data/lib/nokogiri/ffi/structs/xml_attr.rb +19 -0
- data/lib/nokogiri/ffi/structs/xml_buffer.rb +16 -0
- data/lib/nokogiri/ffi/structs/xml_document.rb +108 -0
- data/lib/nokogiri/ffi/structs/xml_dtd.rb +26 -0
- data/lib/nokogiri/ffi/structs/xml_node.rb +28 -0
- data/lib/nokogiri/ffi/structs/xml_node_set.rb +53 -0
- data/lib/nokogiri/ffi/structs/xml_notation.rb +11 -0
- data/lib/nokogiri/ffi/structs/xml_ns.rb +15 -0
- data/lib/nokogiri/ffi/structs/xml_relax_ng.rb +14 -0
- data/lib/nokogiri/ffi/structs/xml_sax_handler.rb +51 -0
- data/lib/nokogiri/ffi/structs/xml_sax_push_parser_context.rb +14 -0
- data/lib/nokogiri/ffi/structs/xml_schema.rb +13 -0
- data/lib/nokogiri/ffi/structs/xml_syntax_error.rb +31 -0
- data/lib/nokogiri/ffi/structs/xml_text_reader.rb +12 -0
- data/lib/nokogiri/ffi/structs/xml_xpath_context.rb +37 -0
- data/lib/nokogiri/ffi/structs/xml_xpath_object.rb +35 -0
- data/lib/nokogiri/ffi/structs/xml_xpath_parser_context.rb +20 -0
- data/lib/nokogiri/ffi/structs/xslt_stylesheet.rb +13 -0
- data/lib/nokogiri/ffi/xml/attr.rb +41 -0
- data/lib/nokogiri/ffi/xml/cdata.rb +19 -0
- data/lib/nokogiri/ffi/xml/comment.rb +18 -0
- data/lib/nokogiri/ffi/xml/document.rb +107 -0
- data/lib/nokogiri/ffi/xml/document_fragment.rb +26 -0
- data/lib/nokogiri/ffi/xml/dtd.rb +42 -0
- data/lib/nokogiri/ffi/xml/entity_reference.rb +19 -0
- data/lib/nokogiri/ffi/xml/namespace.rb +38 -0
- data/lib/nokogiri/ffi/xml/node.rb +380 -0
- data/lib/nokogiri/ffi/xml/node_set.rb +130 -0
- data/lib/nokogiri/ffi/xml/processing_instruction.rb +20 -0
- data/lib/nokogiri/ffi/xml/reader.rb +217 -0
- data/lib/nokogiri/ffi/xml/relax_ng.rb +51 -0
- data/lib/nokogiri/ffi/xml/sax/parser.rb +148 -0
- data/lib/nokogiri/ffi/xml/sax/push_parser.rb +38 -0
- data/lib/nokogiri/ffi/xml/schema.rb +55 -0
- data/lib/nokogiri/ffi/xml/syntax_error.rb +76 -0
- data/lib/nokogiri/ffi/xml/text.rb +18 -0
- data/lib/nokogiri/ffi/xml/xpath.rb +19 -0
- data/lib/nokogiri/ffi/xml/xpath_context.rb +135 -0
- data/lib/nokogiri/ffi/xslt/stylesheet.rb +47 -0
- data/lib/nokogiri/hpricot.rb +62 -0
- data/lib/nokogiri/html.rb +34 -0
- data/lib/nokogiri/html/builder.rb +35 -0
- data/lib/nokogiri/html/document.rb +71 -0
- data/lib/nokogiri/html/document_fragment.rb +15 -0
- data/lib/nokogiri/html/element_description.rb +23 -0
- data/lib/nokogiri/html/entity_lookup.rb +13 -0
- data/lib/nokogiri/html/sax/parser.rb +47 -0
- data/lib/nokogiri/nokogiri.rb +1 -0
- data/lib/nokogiri/syntax_error.rb +4 -0
- data/lib/nokogiri/version.rb +29 -0
- data/lib/nokogiri/version_warning.rb +11 -0
- data/lib/nokogiri/xml.rb +62 -0
- data/lib/nokogiri/xml/attr.rb +9 -0
- data/lib/nokogiri/xml/builder.rb +254 -0
- data/lib/nokogiri/xml/cdata.rb +11 -0
- data/lib/nokogiri/xml/document.rb +100 -0
- data/lib/nokogiri/xml/document_fragment.rb +49 -0
- data/lib/nokogiri/xml/dtd.rb +11 -0
- data/lib/nokogiri/xml/entity_declaration.rb +11 -0
- data/lib/nokogiri/xml/fragment_handler.rb +55 -0
- data/lib/nokogiri/xml/namespace.rb +7 -0
- data/lib/nokogiri/xml/node.rb +745 -0
- data/lib/nokogiri/xml/node/save_options.rb +42 -0
- data/lib/nokogiri/xml/node_set.rb +238 -0
- data/lib/nokogiri/xml/notation.rb +6 -0
- data/lib/nokogiri/xml/parse_options.rb +80 -0
- data/lib/nokogiri/xml/processing_instruction.rb +8 -0
- data/lib/nokogiri/xml/reader.rb +66 -0
- data/lib/nokogiri/xml/relax_ng.rb +32 -0
- data/lib/nokogiri/xml/sax.rb +3 -0
- data/lib/nokogiri/xml/sax/document.rb +143 -0
- data/lib/nokogiri/xml/sax/parser.rb +101 -0
- data/lib/nokogiri/xml/sax/push_parser.rb +60 -0
- data/lib/nokogiri/xml/schema.rb +65 -0
- data/lib/nokogiri/xml/syntax_error.rb +34 -0
- data/lib/nokogiri/xml/xpath.rb +10 -0
- data/lib/nokogiri/xml/xpath/syntax_error.rb +8 -0
- data/lib/nokogiri/xml/xpath_context.rb +16 -0
- data/lib/nokogiri/xslt.rb +48 -0
- data/lib/nokogiri/xslt/stylesheet.rb +25 -0
- data/lib/xsd/xmlparser/nokogiri.rb +64 -0
- data/tasks/test.rb +161 -0
- data/test/css/test_nthiness.rb +160 -0
- data/test/css/test_parser.rb +277 -0
- data/test/css/test_tokenizer.rb +176 -0
- data/test/css/test_xpath_visitor.rb +76 -0
- data/test/ffi/test_document.rb +35 -0
- data/test/files/address_book.rlx +12 -0
- data/test/files/address_book.xml +10 -0
- data/test/files/dont_hurt_em_why.xml +422 -0
- data/test/files/exslt.xml +8 -0
- data/test/files/exslt.xslt +35 -0
- data/test/files/po.xml +32 -0
- data/test/files/po.xsd +66 -0
- data/test/files/staff.xml +59 -0
- data/test/files/staff.xslt +32 -0
- data/test/files/tlm.html +850 -0
- data/test/helper.rb +123 -0
- data/test/hpricot/files/basic.xhtml +17 -0
- data/test/hpricot/files/boingboing.html +2266 -0
- data/test/hpricot/files/cy0.html +3653 -0
- data/test/hpricot/files/immob.html +400 -0
- data/test/hpricot/files/pace_application.html +1320 -0
- data/test/hpricot/files/tenderlove.html +16 -0
- data/test/hpricot/files/uswebgen.html +220 -0
- data/test/hpricot/files/utf8.html +1054 -0
- data/test/hpricot/files/week9.html +1723 -0
- data/test/hpricot/files/why.xml +19 -0
- data/test/hpricot/load_files.rb +11 -0
- data/test/hpricot/test_alter.rb +68 -0
- data/test/hpricot/test_builder.rb +20 -0
- data/test/hpricot/test_parser.rb +426 -0
- data/test/hpricot/test_paths.rb +15 -0
- data/test/hpricot/test_preserved.rb +77 -0
- data/test/hpricot/test_xml.rb +30 -0
- data/test/html/sax/test_parser.rb +52 -0
- data/test/html/test_builder.rb +156 -0
- data/test/html/test_document.rb +361 -0
- data/test/html/test_document_encoding.rb +46 -0
- data/test/html/test_document_fragment.rb +97 -0
- data/test/html/test_element_description.rb +95 -0
- data/test/html/test_named_characters.rb +14 -0
- data/test/html/test_node.rb +165 -0
- data/test/test_convert_xpath.rb +186 -0
- data/test/test_css_cache.rb +56 -0
- data/test/test_gc.rb +15 -0
- data/test/test_memory_leak.rb +77 -0
- data/test/test_nokogiri.rb +127 -0
- data/test/test_reader.rb +316 -0
- data/test/test_xslt_transforms.rb +131 -0
- data/test/xml/node/test_save_options.rb +20 -0
- data/test/xml/node/test_subclass.rb +44 -0
- data/test/xml/sax/test_parser.rb +169 -0
- data/test/xml/sax/test_push_parser.rb +92 -0
- data/test/xml/test_attr.rb +38 -0
- data/test/xml/test_builder.rb +73 -0
- data/test/xml/test_cdata.rb +38 -0
- data/test/xml/test_comment.rb +23 -0
- data/test/xml/test_document.rb +397 -0
- data/test/xml/test_document_encoding.rb +26 -0
- data/test/xml/test_document_fragment.rb +76 -0
- data/test/xml/test_dtd.rb +42 -0
- data/test/xml/test_dtd_encoding.rb +31 -0
- data/test/xml/test_entity_reference.rb +21 -0
- data/test/xml/test_namespace.rb +43 -0
- data/test/xml/test_node.rb +808 -0
- data/test/xml/test_node_attributes.rb +34 -0
- data/test/xml/test_node_encoding.rb +84 -0
- data/test/xml/test_node_set.rb +368 -0
- data/test/xml/test_parse_options.rb +52 -0
- data/test/xml/test_processing_instruction.rb +30 -0
- data/test/xml/test_reader_encoding.rb +126 -0
- data/test/xml/test_relax_ng.rb +60 -0
- data/test/xml/test_schema.rb +65 -0
- data/test/xml/test_text.rb +18 -0
- data/test/xml/test_unparented_node.rb +381 -0
- data/test/xml/test_xpath.rb +106 -0
- metadata +409 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
<?xml version='1.0'?><rss xmlns:admin='http://webns.net/mvcb/' version='2.0' xmlns:sy='http://purl.org/rss/1.0/modules/syndication/' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
|
2
|
+
<channel>
|
3
|
+
<title>why the lucky stiff</title>
|
4
|
+
<link>http://whytheluckystiff.net</link>
|
5
|
+
<description>hex-editing reality to give us infinite grenades!!</description>
|
6
|
+
<dc:language>en-us</dc:language>
|
7
|
+
<dc:creator/>
|
8
|
+
<dc:date>2007-01-16T22:39:04+00:00</dc:date>
|
9
|
+
<admin:generatorAgent rdf:resource='http://hobix.com/?v=0.4'/>
|
10
|
+
<sy:updatePeriod>hourly</sy:updatePeriod>
|
11
|
+
<sy:updateFrequency>1</sy:updateFrequency>
|
12
|
+
<sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
|
13
|
+
<item><title>1.3</title><link>http://whytheluckystiff.net/quatrains/1.3.html</link><guid isPermaLink='false'>quatrains/1.3@http://whytheluckystiff.net</guid><dc:subject>quatrains</dc:subject><dc:subject>quatrains</dc:subject><dc:creator>why the lucky stiff</dc:creator><dc:date>2007-01-14T08:47:05+00:00</dc:date><description><blockquote>
|
14
|
+
<p>That cadillac of yours and that driver of yours!<br />You and your teacups rattling away in the back seat!<br />You always took the mike, oh, and all those cowboys you shot!<br />I held your hand! And I&#8217;ll shoot a cowboy one day!</p>
|
15
|
+
</blockquote>
|
16
|
+
<blockquote>
|
17
|
+
<p>You said, &#8220;Let&#8217;s run into the woods like kids!&#8221; <br />You said, &#8220;Let&#8217;s rub our hands together super-hot!&#8221; <br />And we scalded the trees and left octagons, I think that was you and<br />You threw parties on the roof!</p>
|
18
|
+
</blockquote></description></item></channel>
|
19
|
+
</rss>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module TestFiles
|
2
|
+
Dir.chdir(File.dirname(__FILE__)) do
|
3
|
+
Dir['files/*.{html,xhtml,xml}'].each do |fname|
|
4
|
+
if RUBY_VERSION >= '1.9'
|
5
|
+
const_set fname[%r!/(\w+)\.\w+$!, 1].upcase, File.open(fname, 'r:ascii-8bit') { |f| f.read }
|
6
|
+
else
|
7
|
+
const_set fname[%r!/(\w+)\.\w+$!, 1].upcase, File.read(fname)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', "helper"))
|
2
|
+
require File.join(File.dirname(__FILE__),"load_files")
|
3
|
+
|
4
|
+
class TestAlter < Nokogiri::TestCase
|
5
|
+
include Nokogiri
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
@basic = Hpricot.parse(TestFiles::BASIC)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_before
|
13
|
+
test0 = "<link rel='stylesheet' href='test0.css' />"
|
14
|
+
@basic.at("link").before(test0)
|
15
|
+
assert_equal 'test0.css', @basic.at("link").attributes['href'].to_s
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_after
|
19
|
+
test_inf = "<link rel='stylesheet' href='test_inf.css' />"
|
20
|
+
@basic.search("link")[-1].after(test_inf)
|
21
|
+
assert_equal 'test_inf.css', @basic.search("link")[-1]['href']
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_wrap
|
25
|
+
ohmy = (@basic/"p.ohmy").wrap("<div id='wrapper'></div>")
|
26
|
+
assert_equal 'wrapper', ohmy[0].parent['id']
|
27
|
+
assert_equal 'ohmy', Nokogiri.Hpricot(@basic.to_html).at("#wrapper").children[0]['class']
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_add_class
|
31
|
+
first_p = (@basic/"p:first").add_class("testing123")
|
32
|
+
assert first_p[0].get_attribute("class").split(" ").include?("testing123")
|
33
|
+
assert((Nokogiri.Hpricot(@basic.to_html)/"p:first")[0]["class"].split(" ").include?("testing123"))
|
34
|
+
####
|
35
|
+
# Modified. We do not support OB1 bug.
|
36
|
+
assert !(Nokogiri.Hpricot(@basic.to_html)/"p:gt(1)")[0]["class"].split(" ").include?("testing123")
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_change_attributes
|
40
|
+
all_ps = (@basic/"p").attr("title", "Some Title")
|
41
|
+
all_as = (@basic/"a").attr("href", "http://my_new_href.com")
|
42
|
+
all_lb = (@basic/"link").attr("href") { |e| e.name }
|
43
|
+
GC.start # try to shake out GC bugs with xpath and node sets.
|
44
|
+
assert_changed(@basic, "p", all_ps) {|p| p.attributes["title"].to_s == "Some Title"}
|
45
|
+
assert_changed(@basic, "a", all_as) {|a| a.attributes["href"].to_s == "http://my_new_href.com"}
|
46
|
+
assert_changed(@basic, "link", all_lb) {|a| a.attributes["href"].to_s == "link" }
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_remove_attr
|
50
|
+
all_rl = (@basic/"link").remove_attr("href")
|
51
|
+
assert_changed(@basic, "link", all_rl) { |link| link['href'].nil? }
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_remove_class
|
55
|
+
all_c1 = (@basic/"p[@class*='last']").remove_class("last")
|
56
|
+
assert_changed(@basic, "p[@class*='last']", all_c1) { |p| p['class'] == 'final' }
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_remove_all_classes
|
60
|
+
all_c2 = (@basic/"p[@class]").remove_class
|
61
|
+
assert_changed(@basic, "p[@class]", all_c2) { |p| p['class'].nil? }
|
62
|
+
end
|
63
|
+
|
64
|
+
def assert_changed original, selector, set, &block
|
65
|
+
assert set.all?(&block)
|
66
|
+
assert Nokogiri.Hpricot(original.to_html).search(selector).all?(&block)
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', "helper"))
|
2
|
+
|
3
|
+
class TestBuilder < Nokogiri::TestCase
|
4
|
+
####
|
5
|
+
# Modified
|
6
|
+
def test_escaping_text
|
7
|
+
doc = Nokogiri.Hpricot() { b "<a\"b>" }
|
8
|
+
assert_match "<b><a\"b></b>", doc.to_html.chomp
|
9
|
+
assert_equal %{<a\"b>}, doc.at("text()").to_s
|
10
|
+
end
|
11
|
+
|
12
|
+
####
|
13
|
+
# Modified
|
14
|
+
def test_no_escaping_text
|
15
|
+
doc = Nokogiri.Hpricot() { div.test.me! { text "<a\"b>" } }
|
16
|
+
assert_match %{<div class="test" id="me"><a"b></div>},
|
17
|
+
doc.to_html.chomp
|
18
|
+
assert_equal %{<a\"b>}, doc.at("text()").to_s
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,426 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', "helper"))
|
2
|
+
require File.join(File.dirname(__FILE__),"load_files")
|
3
|
+
|
4
|
+
class TestParser < Nokogiri::TestCase
|
5
|
+
include Nokogiri
|
6
|
+
|
7
|
+
def test_set_attr
|
8
|
+
@basic = Hpricot.parse(TestFiles::BASIC)
|
9
|
+
@basic.search('//p').set('class', 'para')
|
10
|
+
assert_equal 4, @basic.search('//p').length
|
11
|
+
assert_equal 4, @basic.search('//p').find_all { |x| x['class'] == 'para' }.length
|
12
|
+
end
|
13
|
+
|
14
|
+
# Modified. Not supported
|
15
|
+
## Test creating a new element
|
16
|
+
#def test_new_element
|
17
|
+
# elem = Hpricot::Elem.new(Hpricot::STag.new('form'))
|
18
|
+
# assert_not_nil(elem)
|
19
|
+
# assert_not_nil(elem.attributes)
|
20
|
+
#end
|
21
|
+
|
22
|
+
def test_scan_text
|
23
|
+
assert_equal 'FOO', Hpricot.make("FOO").first.content
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_filter_by_attr
|
27
|
+
@boingboing = Hpricot.parse(TestFiles::BOINGBOING)
|
28
|
+
|
29
|
+
# this link is escaped in the doc
|
30
|
+
link = 'http://www.youtube.com/watch?v=TvSNXyNw26g&search=chris%20ware'
|
31
|
+
assert_equal link, @boingboing.at("a[@href='#{link}']")['href']
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_filter_contains
|
35
|
+
@basic = Hpricot.parse(TestFiles::BASIC)
|
36
|
+
assert_equal '<title>Sample XHTML</title>', @basic.search("title:contains('Sample')").to_s.chomp
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_get_element_by_id
|
40
|
+
@basic = Hpricot.parse(TestFiles::BASIC)
|
41
|
+
assert_equal 'link1', @basic.get_element_by_id('link1')['id']
|
42
|
+
assert_equal 'link1', @basic.get_element_by_id('body1').get_element_by_id('link1').get_attribute('id')
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_get_element_by_tag_name
|
46
|
+
@basic = Hpricot.parse(TestFiles::BASIC)
|
47
|
+
assert_equal 'link1', @basic.get_elements_by_tag_name('a')[0].get_attribute('id')
|
48
|
+
assert_equal 'link1', @basic.get_elements_by_tag_name('body')[0].get_element_by_id('link1').get_attribute('id')
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_output_basic
|
52
|
+
@basic = Hpricot.parse(TestFiles::BASIC)
|
53
|
+
@basic2 = Hpricot.parse(@basic.inner_html)
|
54
|
+
scan_basic @basic2
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_scan_basic
|
58
|
+
@basic = Hpricot.parse(TestFiles::BASIC)
|
59
|
+
scan_basic @basic
|
60
|
+
end
|
61
|
+
|
62
|
+
def scan_basic doc
|
63
|
+
####
|
64
|
+
# Modified: asserting kind is not duck typey
|
65
|
+
#assert_kind_of Hpricot::XMLDecl, doc.children.first
|
66
|
+
assert_not_equal doc.children.first.to_s, doc.children[1].to_s
|
67
|
+
assert_equal 'link1', doc.at('#link1')['id']
|
68
|
+
assert_equal 'link1', doc.at("p a")['id']
|
69
|
+
assert_equal 'link1', (doc/:p/:a).first['id']
|
70
|
+
assert_equal 'link1', doc.search('p').at('a').get_attribute('id')
|
71
|
+
|
72
|
+
assert_equal 'link2', (doc/'p').filter('.ohmy').search('a').first.get_attribute('id')
|
73
|
+
assert_equal((doc/'p')[2], (doc/'p').filter('[text()="The third paragraph"]')[0])
|
74
|
+
assert_equal((doc/'p')[3], (doc/'p').filter('b')[0])
|
75
|
+
assert_equal((doc/'p')[1], (doc/'p').filter('a[@id="link2"]')[0])
|
76
|
+
assert_equal((doc/'p')[3], (doc/'p').filter('.last')[0])
|
77
|
+
assert_equal 4, (doc/'p').filter('*').length
|
78
|
+
assert_equal 3, (doc/'p').filter('* *').length
|
79
|
+
eles = (doc/'p').filter('.ohmy')
|
80
|
+
assert_equal 1, eles.length
|
81
|
+
assert_equal 'ohmy', eles.first.get_attribute('class')
|
82
|
+
assert_equal 3, (doc/'p:not(.ohmy)').length
|
83
|
+
|
84
|
+
assert_equal 3, (doc/'p').not('.ohmy').length
|
85
|
+
assert_equal 3, (doc/'p').not(eles.first).length
|
86
|
+
assert_equal 2, (doc/'p').filter('[@class]').length
|
87
|
+
assert_equal 'last final', (doc/'p[@class~="final"]').first.get_attribute('class')
|
88
|
+
assert_equal 1, (doc/'p').filter('[@class~="final"]').length
|
89
|
+
assert_equal 2, (doc/'p > a').length
|
90
|
+
assert_equal 1, (doc/'p.ohmy > a').length
|
91
|
+
assert_equal 2, (doc/'p / a').length
|
92
|
+
assert_equal 2, (doc/'link ~ link').length
|
93
|
+
assert_equal 3, (doc/'title ~ link').length
|
94
|
+
assert_equal 5, (doc/"//p/text()").length
|
95
|
+
assert_equal 6, (doc/"//p[a]//text()").length
|
96
|
+
assert_equal 2, (doc/"//p/a/text()").length
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_positional
|
100
|
+
h = Nokogiri.Hpricot( "<div><br/><p>one</p><p>two</p></div>" )
|
101
|
+
assert_equal "<p>one</p>", h.search("div/p:eq(1)").to_s.chomp # MODIFIED: eq(0) -> eq(1), and removed initial '//'
|
102
|
+
assert_equal "<p>one</p>", h.search("div/p:first").to_s.chomp # MODIFIED: removed initial '//'
|
103
|
+
assert_equal "<p>one</p>", h.search("div/p:first()").to_s.chomp # MODIFIED: removed initial '//'
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_pace
|
107
|
+
doc = Nokogiri.Hpricot(TestFiles::PACE_APPLICATION)
|
108
|
+
assert_equal 'get', doc.at('form[@name=frmSect11]')['method']
|
109
|
+
# assert_equal '2', doc.at('#hdnSpouse')['value']
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_scan_boingboing
|
113
|
+
@boingboing = Hpricot.parse(TestFiles::BOINGBOING)
|
114
|
+
assert_equal 60, (@boingboing/'p.posted').length
|
115
|
+
assert_equal 1, @boingboing.search("//a[@name='027906']").length
|
116
|
+
### MODIFIED: libxml wraps the contents of <script> in a CDATA tag, so we won't be able to parse comments.
|
117
|
+
# assert_equal 10, @boingboing.search("script comment()").length
|
118
|
+
assert_equal 3, @boingboing.search("a[text()*='Boing']").length
|
119
|
+
assert_equal 1, @boingboing.search("h3[text()='College kids reportedly taking more smart drugs']").length
|
120
|
+
assert_equal 0, @boingboing.search("h3[text()='College']").length
|
121
|
+
assert_equal 60, @boingboing.search("h3").length
|
122
|
+
assert_equal 59, @boingboing.search("h3[text()!='College kids reportedly taking more smart drugs']").length
|
123
|
+
assert_equal 17, @boingboing.search("h3[text()$='s']").length
|
124
|
+
### Modified. Hpricot is wrong
|
125
|
+
#assert_equal 129, @boingboing.search("p[text()]").length
|
126
|
+
## This test seems to change between libxml versions, so I'm commenting
|
127
|
+
## it out.
|
128
|
+
#if Nokogiri::LIBXML_VERSION == '2.6.16'
|
129
|
+
# assert_equal 111, @boingboing.search("p[text()]").length
|
130
|
+
#else
|
131
|
+
# assert_equal 110, @boingboing.search("p[text()]").length
|
132
|
+
#end
|
133
|
+
assert_equal 211, @boingboing.search("p").length
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_reparent
|
137
|
+
doc = Nokogiri.Hpricot(%{<div id="blurb_1"></div>})
|
138
|
+
div1 = doc.search('#blurb_1')
|
139
|
+
div1.before('<div id="blurb_0"></div>')
|
140
|
+
|
141
|
+
div0 = doc.search('#blurb_0')
|
142
|
+
div0.before('<div id="blurb_a"></div>')
|
143
|
+
|
144
|
+
assert_equal 'div', doc.at('#blurb_1').name
|
145
|
+
end
|
146
|
+
|
147
|
+
def test_siblings
|
148
|
+
@basic = Hpricot.parse(TestFiles::BASIC)
|
149
|
+
t = @basic.at(:title)
|
150
|
+
e = t.next_sibling
|
151
|
+
assert_equal 'test1.css', e['href']
|
152
|
+
assert_equal 'title', e.previous_sibling.name
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_css_negation
|
156
|
+
@basic = Hpricot.parse(TestFiles::BASIC)
|
157
|
+
assert_equal 3, (@basic/'p:not(.final)').length
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_remove_attribute
|
161
|
+
@basic = Hpricot.parse(TestFiles::BASIC)
|
162
|
+
(@basic/:p).each { |ele| ele.remove_attribute('class') }
|
163
|
+
assert_equal 0, (@basic/'p[@class]').length
|
164
|
+
end
|
165
|
+
|
166
|
+
##
|
167
|
+
# Modified: hpricot is giving incorrect counts. Libxml gets it right.
|
168
|
+
def test_abs_xpath
|
169
|
+
@boingboing = Hpricot.parse(TestFiles::BOINGBOING)
|
170
|
+
assert_equal 60, @boingboing.search("/html/body//p[@class='posted']").length
|
171
|
+
assert_equal 60, @boingboing.search("/*/body//p[@class='posted']").length
|
172
|
+
assert_equal 18, @boingboing.search("//script").length
|
173
|
+
divs = @boingboing.search("//script/../div")
|
174
|
+
assert_equal 2, divs.length # hpricot says this is 1, but that's wrong.
|
175
|
+
imgs = @boingboing.search('//div/p/a/img')
|
176
|
+
assert_equal 12, imgs.length # hpricot says this is 15, but that's wrong.
|
177
|
+
assert_equal 16, @boingboing.search('//div').search('p/a/img').length
|
178
|
+
assert imgs.all? { |x| x.name == 'img' }
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_predicates
|
182
|
+
@boingboing = Hpricot.parse(TestFiles::BOINGBOING)
|
183
|
+
assert_equal 2, @boingboing.search('//link[@rel="alternate"]').length
|
184
|
+
p_imgs = @boingboing.search('//div/p[/a/img]')
|
185
|
+
#assert_equal 15, p_imgs.length
|
186
|
+
assert p_imgs.all? { |x| x.name == 'p' }
|
187
|
+
p_imgs = @boingboing.search('//div/p[a/img]')
|
188
|
+
assert_equal 12, p_imgs.length
|
189
|
+
assert p_imgs.all? { |x| x.name == 'p' }
|
190
|
+
assert_equal 1, @boingboing.search('//input[@checked]').length
|
191
|
+
end
|
192
|
+
|
193
|
+
def test_tag_case
|
194
|
+
@tenderlove = Hpricot.parse(TestFiles::TENDERLOVE)
|
195
|
+
assert_equal 2, @tenderlove.search('//a').length
|
196
|
+
assert_equal 3, @tenderlove.search('//area').length
|
197
|
+
assert_equal 2, @tenderlove.search('//meta').length
|
198
|
+
end
|
199
|
+
|
200
|
+
def test_alt_predicates
|
201
|
+
@boingboing = Hpricot.parse(TestFiles::BOINGBOING)
|
202
|
+
assert_equal 2, @boingboing.search('table/tr:last').length # MODIFIED to not have '//' prefix
|
203
|
+
|
204
|
+
@basic = Hpricot.parse(TestFiles::BASIC)
|
205
|
+
##
|
206
|
+
# MODIFIED:
|
207
|
+
# hpricot has an off-by-one bug eith eq-and-friends.
|
208
|
+
assert_equal "<p>The third paragraph</p>",
|
209
|
+
@basic.search('p:eq(3)').to_html.chomp # under Hpricot this was eq(2)
|
210
|
+
##
|
211
|
+
# MODIFIED: to be blank-agnostic, because Nokogiri's to_html is slightly different compared to Hpricot.
|
212
|
+
assert_equal '<p class="last final"><b>THE FINAL PARAGRAPH</b></p>',
|
213
|
+
@basic.search('p:last').to_html.gsub(/\s+/,' ').gsub(/>\s*</, '><')
|
214
|
+
assert_equal 'last final', @basic.search('p:last-of-type').first.get_attribute('class') # MODIFIED to not have '//' prefix
|
215
|
+
end
|
216
|
+
|
217
|
+
def test_insert_after # ticket #63
|
218
|
+
doc = Nokogiri.Hpricot('<html><body><div id="a-div"></div></body></html>')
|
219
|
+
(doc/'div').each do |element|
|
220
|
+
element.after('<p>Paragraph 1</p><p>Paragraph 2</p>')
|
221
|
+
end
|
222
|
+
assert_match '<div id="a-div"></div><p>Paragraph 1</p><p>Paragraph 2</p>',
|
223
|
+
doc.to_html.gsub(/\n/, '').gsub(/>\s*</, '><')
|
224
|
+
end
|
225
|
+
|
226
|
+
def test_insert_before # ticket #61
|
227
|
+
doc = Nokogiri.Hpricot('<html><body><div id="a-div"></div></body></html>')
|
228
|
+
(doc/'div').each do |element|
|
229
|
+
element.before('<p>Paragraph 1</p><p>Paragraph 2</p>')
|
230
|
+
end
|
231
|
+
assert_match '<p>Paragraph 1</p><p>Paragraph 2</p><div id="a-div"></div>',
|
232
|
+
doc.to_html.gsub(/\n/, '').gsub(/>\s*</, '><')
|
233
|
+
end
|
234
|
+
|
235
|
+
def test_many_paths
|
236
|
+
@boingboing = Hpricot.parse(TestFiles::BOINGBOING)
|
237
|
+
assert_equal 62, @boingboing.search('p.posted, link[@rel="alternate"]').length
|
238
|
+
###
|
239
|
+
# Modified. I don't want to support this syntax. Just use a comma.
|
240
|
+
#assert_equal 20, @boingboing.search('//div/p[a/img]|//link[@rel="alternate"]').length
|
241
|
+
end
|
242
|
+
|
243
|
+
####
|
244
|
+
# Modified. Epic Fail. We're on the duck type train folks.
|
245
|
+
#def test_stacked_search
|
246
|
+
# @boingboing = Hpricot.parse(TestFiles::BOINGBOING)
|
247
|
+
# assert_kind_of Hpricot::Elements, @boingboing.search('//div/p').search('a img')
|
248
|
+
#end
|
249
|
+
|
250
|
+
def test_class_search
|
251
|
+
# test case sent by Chih-Chao Lam
|
252
|
+
# Modified. libxml corrects this differently than hpricot
|
253
|
+
doc = Nokogiri::Hpricot.HTML("<div class=xyz '>abc</div>")
|
254
|
+
assert_equal 1, doc.search(".xyz").length
|
255
|
+
|
256
|
+
doc = Nokogiri::Hpricot.HTML("<div class=xyz>abc</div><div class=abc>xyz</div>")
|
257
|
+
assert_equal 1, doc.search(".xyz").length
|
258
|
+
assert_equal 4, doc.search("*").length
|
259
|
+
end
|
260
|
+
|
261
|
+
def test_kleene_star
|
262
|
+
# bug noticed by raja bhatia
|
263
|
+
doc = Nokogiri::Hpricot.HTML("<span class='small'>1</span><div class='large'>2</div><div class='small'>3</div><span class='blue large'>4</span>")
|
264
|
+
assert_equal 2, doc.search("*[@class*='small']").length
|
265
|
+
assert_equal 2, doc.search("*.small").length
|
266
|
+
assert_equal 2, doc.search(".small").length
|
267
|
+
assert_equal 2, doc.search(".large").length
|
268
|
+
end
|
269
|
+
|
270
|
+
def test_empty_comment
|
271
|
+
doc = Nokogiri::Hpricot.HTML("<p><!----></p>")
|
272
|
+
doc = doc.search('//body').first
|
273
|
+
assert doc.children[0].children[0].comment?
|
274
|
+
|
275
|
+
doc = Nokogiri::Hpricot.HTML("<p><!-- --></p>")
|
276
|
+
doc = doc.search('//body').first
|
277
|
+
assert doc.children[0].children[0].comment?
|
278
|
+
end
|
279
|
+
|
280
|
+
def test_body_newlines
|
281
|
+
@immob = Hpricot.parse(TestFiles::IMMOB)
|
282
|
+
body = @immob.at(:body)
|
283
|
+
{'background' => '', 'bgcolor' => '#ffffff', 'text' => '#000000', 'marginheight' => '10',
|
284
|
+
'marginwidth' => '10', 'leftmargin' => '10', 'topmargin' => '10', 'link' => '#000066',
|
285
|
+
'alink' => '#ff6600', 'hlink' => "#ff6600", 'vlink' => "#000000"}.each do |k, v|
|
286
|
+
assert_equal v, body[k]
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
def test_nested_twins
|
291
|
+
@doc = Nokogiri.Hpricot("<div>Hi<div>there</div></div>")
|
292
|
+
assert_equal 1, (@doc/"div div").length
|
293
|
+
end
|
294
|
+
|
295
|
+
def test_wildcard
|
296
|
+
@basic = Hpricot.parse(TestFiles::BASIC)
|
297
|
+
assert_equal 3, (@basic/"*[@id]").length
|
298
|
+
assert_equal 3, (@basic/"//*[@id]").length
|
299
|
+
end
|
300
|
+
|
301
|
+
def test_javascripts
|
302
|
+
@immob = Hpricot.parse(TestFiles::IMMOB)
|
303
|
+
assert_equal 3, (@immob/:script)[0].inner_html.scan(/<LINK/).length
|
304
|
+
end
|
305
|
+
|
306
|
+
####
|
307
|
+
# Modified. This test passes with later versions of libxml
|
308
|
+
def test_nested_scripts
|
309
|
+
@week9 = Hpricot.parse(TestFiles::WEEK9)
|
310
|
+
unless Nokogiri::LIBXML_VERSION == '2.6.16'
|
311
|
+
assert_equal 14, (@week9/"a").find_all { |x| x.inner_html.include? "GameCenter" }.length
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
def test_uswebgen
|
316
|
+
@uswebgen = Hpricot.parse(TestFiles::USWEBGEN)
|
317
|
+
# sent by brent beardsley, nokogiri 0.3 had problems with all the links.
|
318
|
+
assert_equal 67, (@uswebgen/:a).length
|
319
|
+
end
|
320
|
+
|
321
|
+
def test_mangled_tags
|
322
|
+
[%{<html><form name='loginForm' method='post' action='/units/a/login/1,13088,779-1,00.html'?URL=></form></html>},
|
323
|
+
%{<html><form name='loginForm' ?URL= method='post' action='/units/a/login/1,13088,779-1,00.html'></form></html>},
|
324
|
+
%{<html><form name='loginForm'?URL= ?URL= method='post' action='/units/a/login/1,13088,779-1,00.html'?URL=></form></html>},
|
325
|
+
%{<html><form name='loginForm' method='post' action='/units/a/login/1,13088,779-1,00.html' ?URL=></form></html>}].
|
326
|
+
each do |str|
|
327
|
+
doc = Nokogiri.Hpricot(str)
|
328
|
+
assert_equal 1, (doc/:form).length
|
329
|
+
assert_equal '/units/a/login/1,13088,779-1,00.html', doc.at("form")['action']
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
####
|
334
|
+
# Modified. Added question. Don't care.
|
335
|
+
def test_procins
|
336
|
+
doc = Nokogiri::Hpricot.HTML("<?php print('hello') ?>\n<?xml blah='blah'?>")
|
337
|
+
assert_equal "php", doc.children[1].target
|
338
|
+
assert_equal "blah='blah'?", doc.children[2].content #"# quote added so emacs ruby-mode parser doesn't barf
|
339
|
+
end
|
340
|
+
|
341
|
+
####
|
342
|
+
# Altered... libxml does not get a buffer error
|
343
|
+
def test_buffer_error
|
344
|
+
assert_nothing_raised {
|
345
|
+
Nokogiri.Hpricot(%{<p>\n\n<input type="hidden" name="__VIEWSTATE" value="#{(("X" * 2000) + "\n") * 22}" />\n\n</p>})
|
346
|
+
}
|
347
|
+
end
|
348
|
+
|
349
|
+
def test_youtube_attr
|
350
|
+
str = <<-edoc
|
351
|
+
<html><body>
|
352
|
+
Lorem ipsum. Jolly roger, ding-dong sing-a-long
|
353
|
+
<object width="425" height="350">
|
354
|
+
<param name="movie" value="http://www.youtube.com/v/NbDQ4M_cuwA"></param>
|
355
|
+
<param name="wmode" value="transparent"></param>
|
356
|
+
<embed src="http://www.youtube.com/v/NbDQ4M_cuwA"
|
357
|
+
type="application/x-shockwave-flash" wmode="transparent" width="425" height="350">
|
358
|
+
</embed>
|
359
|
+
</object>
|
360
|
+
Check out my posting, I have bright mice in large clown cars.
|
361
|
+
<object width="425" height="350">
|
362
|
+
<param name="movie" value="http://www.youtube.com/v/foobar"></param>
|
363
|
+
<param name="wmode" value="transparent"></param>
|
364
|
+
<embed src="http://www.youtube.com/v/foobar"
|
365
|
+
type="application/x-shockwave-flash" wmode="transparent" width="425" height="350">
|
366
|
+
</embed>
|
367
|
+
</object>
|
368
|
+
</body></html?
|
369
|
+
edoc
|
370
|
+
doc = Nokogiri.Hpricot(str)
|
371
|
+
assert_equal "http://www.youtube.com/v/NbDQ4M_cuwA",
|
372
|
+
doc.at("//object/param[@value='http://www.youtube.com/v/NbDQ4M_cuwA']")['value']
|
373
|
+
end
|
374
|
+
|
375
|
+
# ticket #84 by jamezilla
|
376
|
+
def test_screwed_xmlns
|
377
|
+
doc = Nokogiri.Hpricot(<<-edoc)
|
378
|
+
<?xml:namespace prefix = cwi />
|
379
|
+
<html><body>HAI</body></html>
|
380
|
+
edoc
|
381
|
+
assert_equal "HAI", doc.at("body").inner_text
|
382
|
+
end
|
383
|
+
|
384
|
+
# Reported by Jonathan Nichols on the Hpricot list (24 May 2007)
|
385
|
+
# MODIFIED: This is an issue with libxml which we cannot deal with....
|
386
|
+
#def test_self_closed_form
|
387
|
+
# doc = Nokogiri.Hpricot(<<-edoc)
|
388
|
+
# <body>
|
389
|
+
# <form action="/loginRegForm" name="regForm" method="POST" />
|
390
|
+
# <input type="button">
|
391
|
+
# </form>
|
392
|
+
# </body>
|
393
|
+
# edoc
|
394
|
+
# assert_equal "button", doc.at("//form/input")['type']
|
395
|
+
#end
|
396
|
+
|
397
|
+
def test_filters
|
398
|
+
@basic = Hpricot.parse(TestFiles::BASIC)
|
399
|
+
##
|
400
|
+
# MODIFIED:
|
401
|
+
# Hpricot considers nodes with text-only (but no child tags) to be empty.
|
402
|
+
# Nokogiri considers that any content makes a parent.
|
403
|
+
assert_equal 1, (@basic/"title:parent").size # so this was 0 under Hpricot
|
404
|
+
assert_equal 4, (@basic/"p:parent").size
|
405
|
+
assert_equal 0, (@basic/"title:empty").size
|
406
|
+
assert_equal 3, (@basic/"link:empty").size
|
407
|
+
end
|
408
|
+
|
409
|
+
def test_keep_cdata
|
410
|
+
str = %{<script> /*<![CDATA[*/
|
411
|
+
/*]]>*/ </script>}
|
412
|
+
# MODIFIED: if you want the cdata, to_xml it
|
413
|
+
assert_match str, Nokogiri.Hpricot(str).to_xml
|
414
|
+
end
|
415
|
+
|
416
|
+
def test_namespace
|
417
|
+
chunk = <<-END
|
418
|
+
<a xmlns:t="http://www.nexopia.com/dev/template">
|
419
|
+
<t:sam>hi </t:sam>
|
420
|
+
</a>
|
421
|
+
END
|
422
|
+
doc = Hpricot::XML(chunk)
|
423
|
+
assert((doc/"//t:sam").size > 0) # at least this should probably work
|
424
|
+
# assert (doc/"//sam").size > 0 # this would be nice
|
425
|
+
end
|
426
|
+
end
|