nokogiri 1.8.5 → 1.13.6

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.

Files changed (356) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -21
  3. data/LICENSE-DEPENDENCIES.md +1159 -868
  4. data/LICENSE.md +5 -28
  5. data/README.md +196 -90
  6. data/bin/nokogiri +63 -50
  7. data/dependencies.yml +13 -59
  8. data/ext/nokogiri/depend +38 -358
  9. data/ext/nokogiri/extconf.rb +750 -420
  10. data/ext/nokogiri/gumbo.c +584 -0
  11. data/ext/nokogiri/html4_document.c +166 -0
  12. data/ext/nokogiri/html4_element_description.c +294 -0
  13. data/ext/nokogiri/html4_entity_lookup.c +37 -0
  14. data/ext/nokogiri/html4_sax_parser_context.c +119 -0
  15. data/ext/nokogiri/html4_sax_push_parser.c +95 -0
  16. data/ext/nokogiri/libxml2_backwards_compat.c +121 -0
  17. data/ext/nokogiri/nokogiri.c +228 -91
  18. data/ext/nokogiri/nokogiri.h +191 -89
  19. data/ext/nokogiri/test_global_handlers.c +40 -0
  20. data/ext/nokogiri/xml_attr.c +41 -36
  21. data/ext/nokogiri/xml_attribute_decl.c +18 -18
  22. data/ext/nokogiri/xml_cdata.c +13 -18
  23. data/ext/nokogiri/xml_comment.c +19 -26
  24. data/ext/nokogiri/xml_document.c +291 -216
  25. data/ext/nokogiri/xml_document_fragment.c +12 -16
  26. data/ext/nokogiri/xml_dtd.c +56 -50
  27. data/ext/nokogiri/xml_element_content.c +31 -26
  28. data/ext/nokogiri/xml_element_decl.c +22 -22
  29. data/ext/nokogiri/xml_encoding_handler.c +43 -18
  30. data/ext/nokogiri/xml_entity_decl.c +32 -30
  31. data/ext/nokogiri/xml_entity_reference.c +16 -18
  32. data/ext/nokogiri/xml_namespace.c +61 -52
  33. data/ext/nokogiri/xml_node.c +1044 -616
  34. data/ext/nokogiri/xml_node_set.c +174 -162
  35. data/ext/nokogiri/xml_processing_instruction.c +17 -19
  36. data/ext/nokogiri/xml_reader.c +226 -175
  37. data/ext/nokogiri/xml_relax_ng.c +52 -28
  38. data/ext/nokogiri/xml_sax_parser.c +112 -112
  39. data/ext/nokogiri/xml_sax_parser_context.c +112 -86
  40. data/ext/nokogiri/xml_sax_push_parser.c +36 -27
  41. data/ext/nokogiri/xml_schema.c +112 -33
  42. data/ext/nokogiri/xml_syntax_error.c +42 -21
  43. data/ext/nokogiri/xml_text.c +13 -17
  44. data/ext/nokogiri/xml_xpath_context.c +223 -115
  45. data/ext/nokogiri/xslt_stylesheet.c +265 -173
  46. data/gumbo-parser/CHANGES.md +63 -0
  47. data/gumbo-parser/Makefile +101 -0
  48. data/gumbo-parser/THANKS +27 -0
  49. data/gumbo-parser/src/Makefile +34 -0
  50. data/gumbo-parser/src/README.md +41 -0
  51. data/gumbo-parser/src/ascii.c +75 -0
  52. data/gumbo-parser/src/ascii.h +115 -0
  53. data/gumbo-parser/src/attribute.c +42 -0
  54. data/gumbo-parser/src/attribute.h +17 -0
  55. data/gumbo-parser/src/char_ref.c +22225 -0
  56. data/gumbo-parser/src/char_ref.h +29 -0
  57. data/gumbo-parser/src/char_ref.rl +2154 -0
  58. data/gumbo-parser/src/error.c +626 -0
  59. data/gumbo-parser/src/error.h +148 -0
  60. data/gumbo-parser/src/foreign_attrs.c +104 -0
  61. data/gumbo-parser/src/foreign_attrs.gperf +27 -0
  62. data/gumbo-parser/src/gumbo.h +943 -0
  63. data/gumbo-parser/src/insertion_mode.h +33 -0
  64. data/gumbo-parser/src/macros.h +91 -0
  65. data/gumbo-parser/src/parser.c +4875 -0
  66. data/gumbo-parser/src/parser.h +41 -0
  67. data/gumbo-parser/src/replacement.h +33 -0
  68. data/gumbo-parser/src/string_buffer.c +103 -0
  69. data/gumbo-parser/src/string_buffer.h +68 -0
  70. data/gumbo-parser/src/string_piece.c +48 -0
  71. data/gumbo-parser/src/svg_attrs.c +174 -0
  72. data/gumbo-parser/src/svg_attrs.gperf +77 -0
  73. data/gumbo-parser/src/svg_tags.c +137 -0
  74. data/gumbo-parser/src/svg_tags.gperf +55 -0
  75. data/gumbo-parser/src/tag.c +222 -0
  76. data/gumbo-parser/src/tag_lookup.c +382 -0
  77. data/gumbo-parser/src/tag_lookup.gperf +169 -0
  78. data/gumbo-parser/src/tag_lookup.h +13 -0
  79. data/gumbo-parser/src/token_buffer.c +79 -0
  80. data/gumbo-parser/src/token_buffer.h +71 -0
  81. data/gumbo-parser/src/token_type.h +17 -0
  82. data/gumbo-parser/src/tokenizer.c +3463 -0
  83. data/gumbo-parser/src/tokenizer.h +112 -0
  84. data/gumbo-parser/src/tokenizer_states.h +339 -0
  85. data/gumbo-parser/src/utf8.c +245 -0
  86. data/gumbo-parser/src/utf8.h +164 -0
  87. data/gumbo-parser/src/util.c +68 -0
  88. data/gumbo-parser/src/util.h +30 -0
  89. data/gumbo-parser/src/vector.c +111 -0
  90. data/gumbo-parser/src/vector.h +45 -0
  91. data/lib/nokogiri/class_resolver.rb +67 -0
  92. data/lib/nokogiri/css/node.rb +10 -8
  93. data/lib/nokogiri/css/parser.rb +397 -377
  94. data/lib/nokogiri/css/parser.y +250 -245
  95. data/lib/nokogiri/css/parser_extras.rb +54 -49
  96. data/lib/nokogiri/css/syntax_error.rb +3 -1
  97. data/lib/nokogiri/css/tokenizer.rb +107 -104
  98. data/lib/nokogiri/css/tokenizer.rex +3 -2
  99. data/lib/nokogiri/css/xpath_visitor.rb +218 -91
  100. data/lib/nokogiri/css.rb +50 -17
  101. data/lib/nokogiri/decorators/slop.rb +9 -7
  102. data/lib/nokogiri/extension.rb +31 -0
  103. data/lib/nokogiri/gumbo.rb +15 -0
  104. data/lib/nokogiri/html.rb +38 -27
  105. data/lib/nokogiri/{html → html4}/builder.rb +4 -2
  106. data/lib/nokogiri/{html → html4}/document.rb +103 -105
  107. data/lib/nokogiri/html4/document_fragment.rb +54 -0
  108. data/lib/nokogiri/{html → html4}/element_description.rb +3 -1
  109. data/lib/nokogiri/html4/element_description_defaults.rb +578 -0
  110. data/lib/nokogiri/{html → html4}/entity_lookup.rb +4 -2
  111. data/lib/nokogiri/{html → html4}/sax/parser.rb +17 -16
  112. data/lib/nokogiri/html4/sax/parser_context.rb +20 -0
  113. data/lib/nokogiri/{html → html4}/sax/push_parser.rb +12 -11
  114. data/lib/nokogiri/html4.rb +46 -0
  115. data/lib/nokogiri/html5/document.rb +91 -0
  116. data/lib/nokogiri/html5/document_fragment.rb +83 -0
  117. data/lib/nokogiri/html5/node.rb +100 -0
  118. data/lib/nokogiri/html5.rb +478 -0
  119. data/lib/nokogiri/jruby/dependencies.rb +21 -0
  120. data/lib/nokogiri/syntax_error.rb +2 -0
  121. data/lib/nokogiri/version/constant.rb +6 -0
  122. data/lib/nokogiri/version/info.rb +222 -0
  123. data/lib/nokogiri/version.rb +3 -108
  124. data/lib/nokogiri/xml/attr.rb +6 -3
  125. data/lib/nokogiri/xml/attribute_decl.rb +3 -1
  126. data/lib/nokogiri/xml/builder.rb +97 -53
  127. data/lib/nokogiri/xml/cdata.rb +3 -1
  128. data/lib/nokogiri/xml/character_data.rb +2 -0
  129. data/lib/nokogiri/xml/document.rb +224 -86
  130. data/lib/nokogiri/xml/document_fragment.rb +57 -44
  131. data/lib/nokogiri/xml/dtd.rb +4 -2
  132. data/lib/nokogiri/xml/element_content.rb +2 -0
  133. data/lib/nokogiri/xml/element_decl.rb +3 -1
  134. data/lib/nokogiri/xml/entity_decl.rb +4 -2
  135. data/lib/nokogiri/xml/entity_reference.rb +2 -0
  136. data/lib/nokogiri/xml/namespace.rb +3 -0
  137. data/lib/nokogiri/xml/node/save_options.rb +10 -5
  138. data/lib/nokogiri/xml/node.rb +895 -377
  139. data/lib/nokogiri/xml/node_set.rb +92 -65
  140. data/lib/nokogiri/xml/notation.rb +13 -0
  141. data/lib/nokogiri/xml/parse_options.rb +22 -8
  142. data/lib/nokogiri/xml/pp/character_data.rb +9 -6
  143. data/lib/nokogiri/xml/pp/node.rb +25 -26
  144. data/lib/nokogiri/xml/pp.rb +4 -2
  145. data/lib/nokogiri/xml/processing_instruction.rb +3 -1
  146. data/lib/nokogiri/xml/reader.rb +23 -28
  147. data/lib/nokogiri/xml/relax_ng.rb +8 -2
  148. data/lib/nokogiri/xml/sax/document.rb +45 -49
  149. data/lib/nokogiri/xml/sax/parser.rb +38 -34
  150. data/lib/nokogiri/xml/sax/parser_context.rb +8 -3
  151. data/lib/nokogiri/xml/sax/push_parser.rb +6 -5
  152. data/lib/nokogiri/xml/sax.rb +6 -4
  153. data/lib/nokogiri/xml/schema.rb +19 -9
  154. data/lib/nokogiri/xml/searchable.rb +112 -72
  155. data/lib/nokogiri/xml/syntax_error.rb +6 -4
  156. data/lib/nokogiri/xml/text.rb +2 -0
  157. data/lib/nokogiri/xml/xpath/syntax_error.rb +4 -2
  158. data/lib/nokogiri/xml/xpath.rb +15 -4
  159. data/lib/nokogiri/xml/xpath_context.rb +3 -3
  160. data/lib/nokogiri/xml.rb +38 -37
  161. data/lib/nokogiri/xslt/stylesheet.rb +3 -1
  162. data/lib/nokogiri/xslt.rb +29 -20
  163. data/lib/nokogiri.rb +49 -65
  164. data/lib/xsd/xmlparser/nokogiri.rb +26 -24
  165. data/patches/libxml2/0001-Remove-script-macro-support.patch +40 -0
  166. data/patches/libxml2/0002-Update-entities-to-remove-handling-of-ssi.patch +44 -0
  167. data/patches/libxml2/0003-libxml2.la-is-in-top_builddir.patch +25 -0
  168. data/patches/libxml2/0004-use-glibc-strlen.patch +53 -0
  169. data/patches/libxml2/0005-avoid-isnan-isinf.patch +81 -0
  170. data/patches/libxml2/0006-update-automake-files-for-arm64.patch +3040 -0
  171. data/patches/libxml2/0008-htmlParseComment-handle-abruptly-closed-comments.patch +61 -0
  172. data/patches/libxml2/0009-allow-wildcard-namespaces.patch +77 -0
  173. data/patches/libxslt/0001-update-automake-files-for-arm64.patch +3037 -0
  174. data/ports/archives/libxml2-2.9.14.tar.xz +0 -0
  175. data/ports/archives/libxslt-1.1.35.tar.xz +0 -0
  176. metadata +220 -266
  177. data/.autotest +0 -22
  178. data/.cross_rubies +0 -8
  179. data/.editorconfig +0 -17
  180. data/.gemtest +0 -0
  181. data/.travis.yml +0 -63
  182. data/CHANGELOG.md +0 -1368
  183. data/CONTRIBUTING.md +0 -42
  184. data/C_CODING_STYLE.rdoc +0 -33
  185. data/Gemfile-libxml-ruby +0 -3
  186. data/Manifest.txt +0 -370
  187. data/ROADMAP.md +0 -111
  188. data/Rakefile +0 -348
  189. data/SECURITY.md +0 -19
  190. data/STANDARD_RESPONSES.md +0 -47
  191. data/Y_U_NO_GEMSPEC.md +0 -155
  192. data/appveyor.yml +0 -29
  193. data/build_all +0 -44
  194. data/ext/nokogiri/html_document.c +0 -170
  195. data/ext/nokogiri/html_document.h +0 -10
  196. data/ext/nokogiri/html_element_description.c +0 -279
  197. data/ext/nokogiri/html_element_description.h +0 -10
  198. data/ext/nokogiri/html_entity_lookup.c +0 -32
  199. data/ext/nokogiri/html_entity_lookup.h +0 -8
  200. data/ext/nokogiri/html_sax_parser_context.c +0 -116
  201. data/ext/nokogiri/html_sax_parser_context.h +0 -11
  202. data/ext/nokogiri/html_sax_push_parser.c +0 -87
  203. data/ext/nokogiri/html_sax_push_parser.h +0 -9
  204. data/ext/nokogiri/xml_attr.h +0 -9
  205. data/ext/nokogiri/xml_attribute_decl.h +0 -9
  206. data/ext/nokogiri/xml_cdata.h +0 -9
  207. data/ext/nokogiri/xml_comment.h +0 -9
  208. data/ext/nokogiri/xml_document.h +0 -23
  209. data/ext/nokogiri/xml_document_fragment.h +0 -10
  210. data/ext/nokogiri/xml_dtd.h +0 -10
  211. data/ext/nokogiri/xml_element_content.h +0 -10
  212. data/ext/nokogiri/xml_element_decl.h +0 -9
  213. data/ext/nokogiri/xml_encoding_handler.h +0 -8
  214. data/ext/nokogiri/xml_entity_decl.h +0 -10
  215. data/ext/nokogiri/xml_entity_reference.h +0 -9
  216. data/ext/nokogiri/xml_io.c +0 -61
  217. data/ext/nokogiri/xml_io.h +0 -11
  218. data/ext/nokogiri/xml_libxml2_hacks.c +0 -112
  219. data/ext/nokogiri/xml_libxml2_hacks.h +0 -12
  220. data/ext/nokogiri/xml_namespace.h +0 -15
  221. data/ext/nokogiri/xml_node.h +0 -13
  222. data/ext/nokogiri/xml_node_set.h +0 -12
  223. data/ext/nokogiri/xml_processing_instruction.h +0 -9
  224. data/ext/nokogiri/xml_reader.h +0 -10
  225. data/ext/nokogiri/xml_relax_ng.h +0 -9
  226. data/ext/nokogiri/xml_sax_parser.h +0 -39
  227. data/ext/nokogiri/xml_sax_parser_context.h +0 -10
  228. data/ext/nokogiri/xml_sax_push_parser.h +0 -9
  229. data/ext/nokogiri/xml_schema.h +0 -9
  230. data/ext/nokogiri/xml_syntax_error.h +0 -13
  231. data/ext/nokogiri/xml_text.h +0 -9
  232. data/ext/nokogiri/xml_xpath_context.h +0 -10
  233. data/ext/nokogiri/xslt_stylesheet.h +0 -14
  234. data/lib/nokogiri/html/document_fragment.rb +0 -49
  235. data/lib/nokogiri/html/element_description_defaults.rb +0 -671
  236. data/lib/nokogiri/html/sax/parser_context.rb +0 -16
  237. data/patches/libxml2/0001-Revert-Do-not-URI-escape-in-server-side-includes.patch +0 -78
  238. data/patches/libxml2/0002-Fix-nullptr-deref-with-XPath-logic-ops.patch +0 -54
  239. data/patches/libxml2/0003-Fix-infinite-loop-in-LZMA-decompression.patch +0 -50
  240. data/patches/sort-patches-by-date +0 -25
  241. data/ports/archives/libxml2-2.9.8.tar.gz +0 -0
  242. data/ports/archives/libxslt-1.1.32.tar.gz +0 -0
  243. data/suppressions/README.txt +0 -1
  244. data/suppressions/nokogiri_ruby-2.supp +0 -10
  245. data/tasks/test.rb +0 -100
  246. data/test/css/test_nthiness.rb +0 -226
  247. data/test/css/test_parser.rb +0 -386
  248. data/test/css/test_tokenizer.rb +0 -215
  249. data/test/css/test_xpath_visitor.rb +0 -96
  250. data/test/decorators/test_slop.rb +0 -23
  251. data/test/files/2ch.html +0 -108
  252. data/test/files/GH_1042.html +0 -18
  253. data/test/files/address_book.rlx +0 -12
  254. data/test/files/address_book.xml +0 -10
  255. data/test/files/atom.xml +0 -344
  256. data/test/files/bar/bar.xsd +0 -4
  257. data/test/files/bogus.xml +0 -0
  258. data/test/files/dont_hurt_em_why.xml +0 -422
  259. data/test/files/encoding.html +0 -82
  260. data/test/files/encoding.xhtml +0 -84
  261. data/test/files/exslt.xml +0 -8
  262. data/test/files/exslt.xslt +0 -35
  263. data/test/files/foo/foo.xsd +0 -4
  264. data/test/files/metacharset.html +0 -10
  265. data/test/files/namespace_pressure_test.xml +0 -1684
  266. data/test/files/noencoding.html +0 -47
  267. data/test/files/po.xml +0 -32
  268. data/test/files/po.xsd +0 -66
  269. data/test/files/saml/saml20assertion_schema.xsd +0 -283
  270. data/test/files/saml/saml20protocol_schema.xsd +0 -302
  271. data/test/files/saml/xenc_schema.xsd +0 -146
  272. data/test/files/saml/xmldsig_schema.xsd +0 -318
  273. data/test/files/shift_jis.html +0 -10
  274. data/test/files/shift_jis.xml +0 -5
  275. data/test/files/shift_jis_no_charset.html +0 -9
  276. data/test/files/slow-xpath.xml +0 -25509
  277. data/test/files/snuggles.xml +0 -3
  278. data/test/files/staff.dtd +0 -10
  279. data/test/files/staff.xml +0 -59
  280. data/test/files/staff.xslt +0 -32
  281. data/test/files/test_document_url/bar.xml +0 -2
  282. data/test/files/test_document_url/document.dtd +0 -4
  283. data/test/files/test_document_url/document.xml +0 -6
  284. data/test/files/tlm.html +0 -851
  285. data/test/files/to_be_xincluded.xml +0 -2
  286. data/test/files/valid_bar.xml +0 -2
  287. data/test/files/xinclude.xml +0 -4
  288. data/test/helper.rb +0 -271
  289. data/test/html/sax/test_parser.rb +0 -168
  290. data/test/html/sax/test_parser_context.rb +0 -46
  291. data/test/html/sax/test_parser_text.rb +0 -163
  292. data/test/html/sax/test_push_parser.rb +0 -87
  293. data/test/html/test_attributes.rb +0 -85
  294. data/test/html/test_builder.rb +0 -164
  295. data/test/html/test_document.rb +0 -712
  296. data/test/html/test_document_encoding.rb +0 -143
  297. data/test/html/test_document_fragment.rb +0 -310
  298. data/test/html/test_element_description.rb +0 -105
  299. data/test/html/test_named_characters.rb +0 -14
  300. data/test/html/test_node.rb +0 -212
  301. data/test/html/test_node_encoding.rb +0 -91
  302. data/test/namespaces/test_additional_namespaces_in_builder_doc.rb +0 -14
  303. data/test/namespaces/test_namespaces_aliased_default.rb +0 -24
  304. data/test/namespaces/test_namespaces_in_builder_doc.rb +0 -75
  305. data/test/namespaces/test_namespaces_in_cloned_doc.rb +0 -31
  306. data/test/namespaces/test_namespaces_in_created_doc.rb +0 -75
  307. data/test/namespaces/test_namespaces_in_parsed_doc.rb +0 -80
  308. data/test/namespaces/test_namespaces_preservation.rb +0 -31
  309. data/test/test_convert_xpath.rb +0 -135
  310. data/test/test_css_cache.rb +0 -47
  311. data/test/test_encoding_handler.rb +0 -48
  312. data/test/test_memory_leak.rb +0 -156
  313. data/test/test_nokogiri.rb +0 -138
  314. data/test/test_soap4r_sax.rb +0 -52
  315. data/test/test_xslt_transforms.rb +0 -314
  316. data/test/xml/node/test_save_options.rb +0 -28
  317. data/test/xml/node/test_subclass.rb +0 -44
  318. data/test/xml/sax/test_parser.rb +0 -402
  319. data/test/xml/sax/test_parser_context.rb +0 -115
  320. data/test/xml/sax/test_parser_text.rb +0 -202
  321. data/test/xml/sax/test_push_parser.rb +0 -265
  322. data/test/xml/test_attr.rb +0 -74
  323. data/test/xml/test_attribute_decl.rb +0 -86
  324. data/test/xml/test_builder.rb +0 -341
  325. data/test/xml/test_c14n.rb +0 -180
  326. data/test/xml/test_cdata.rb +0 -54
  327. data/test/xml/test_comment.rb +0 -40
  328. data/test/xml/test_document.rb +0 -982
  329. data/test/xml/test_document_encoding.rb +0 -31
  330. data/test/xml/test_document_fragment.rb +0 -298
  331. data/test/xml/test_dtd.rb +0 -187
  332. data/test/xml/test_dtd_encoding.rb +0 -31
  333. data/test/xml/test_element_content.rb +0 -56
  334. data/test/xml/test_element_decl.rb +0 -73
  335. data/test/xml/test_entity_decl.rb +0 -122
  336. data/test/xml/test_entity_reference.rb +0 -262
  337. data/test/xml/test_namespace.rb +0 -96
  338. data/test/xml/test_node.rb +0 -1325
  339. data/test/xml/test_node_attributes.rb +0 -115
  340. data/test/xml/test_node_encoding.rb +0 -75
  341. data/test/xml/test_node_inheritance.rb +0 -32
  342. data/test/xml/test_node_reparenting.rb +0 -592
  343. data/test/xml/test_node_set.rb +0 -809
  344. data/test/xml/test_parse_options.rb +0 -64
  345. data/test/xml/test_processing_instruction.rb +0 -30
  346. data/test/xml/test_reader.rb +0 -620
  347. data/test/xml/test_reader_encoding.rb +0 -134
  348. data/test/xml/test_relax_ng.rb +0 -60
  349. data/test/xml/test_schema.rb +0 -142
  350. data/test/xml/test_syntax_error.rb +0 -36
  351. data/test/xml/test_text.rb +0 -60
  352. data/test/xml/test_unparented_node.rb +0 -483
  353. data/test/xml/test_xinclude.rb +0 -83
  354. data/test/xml/test_xpath.rb +0 -470
  355. data/test/xslt/test_custom_functions.rb +0 -133
  356. data/test/xslt/test_exception_handling.rb +0 -37
@@ -1,809 +0,0 @@
1
- require "helper"
2
-
3
- module Nokogiri
4
- module XML
5
- class TestNodeSet < Nokogiri::TestCase
6
- class TestNodeSetNamespaces < Nokogiri::TestCase
7
- def setup
8
- super
9
- @xml = Nokogiri.XML('<foo xmlns:n0="http://example.com" />')
10
- @list = @xml.xpath('//namespace::*')
11
- end
12
-
13
- def test_include?
14
- assert @list.include?(@list.first), 'list should have item'
15
- end
16
-
17
- def test_push
18
- @list.push @list.first
19
- end
20
-
21
- def test_delete
22
- @list.push @list.first
23
- @list.delete @list.first
24
- end
25
-
26
- def test_reference_after_delete
27
- first = @list.first
28
- @list.delete(first)
29
- assert_equal 'http://www.w3.org/XML/1998/namespace', first.href
30
- end
31
- end
32
-
33
- def setup
34
- super
35
- @xml = Nokogiri::XML(File.read(XML_FILE), XML_FILE)
36
- @list = @xml.css('employee')
37
- end
38
-
39
- def test_break_works
40
- assert_equal 7, @xml.root.elements.each { |x| break 7 }
41
- end
42
-
43
- def test_filter
44
- list = @xml.css('address').filter('*[domestic="Yes"]')
45
- assert_equal(%w{ Yes } * 4, list.map { |n| n['domestic'] })
46
- end
47
-
48
- def test_remove_attr
49
- @list.each { |x| x['class'] = 'blah' }
50
- assert_equal @list, @list.remove_attr('class')
51
- @list.each { |x| assert_nil x['class'] }
52
- end
53
-
54
- def test_remove_attribute
55
- @list.each { |x| x['class'] = 'blah' }
56
- assert_equal @list, @list.remove_attribute('class')
57
- @list.each { |x| assert_nil x['class'] }
58
- end
59
-
60
- def test_add_class
61
- assert_equal @list, @list.add_class('bar')
62
- @list.each { |x| assert_equal 'bar', x['class'] }
63
-
64
- @list.add_class('bar')
65
- @list.each { |x| assert_equal 'bar', x['class'] }
66
-
67
- @list.add_class('baz')
68
- @list.each { |x| assert_equal 'bar baz', x['class'] }
69
- end
70
-
71
- def test_append_class
72
- assert_equal @list, @list.append_class('bar')
73
- @list.each { |x| assert_equal 'bar', x['class'] }
74
-
75
- @list.append_class('bar')
76
- @list.each { |x| assert_equal 'bar bar', x['class'] }
77
-
78
- @list.append_class('baz')
79
- @list.each { |x| assert_equal 'bar bar baz', x['class'] }
80
- end
81
-
82
- def test_remove_class_with_no_class
83
- assert_equal @list, @list.remove_class('bar')
84
- @list.each { |e| assert_nil e['class'] }
85
-
86
- @list.each { |e| e['class'] = '' }
87
- assert_equal @list, @list.remove_class('bar')
88
- @list.each { |e| assert_nil e['class'] }
89
- end
90
-
91
- def test_remove_class_single
92
- @list.each { |e| e['class'] = 'foo bar' }
93
-
94
- assert_equal @list, @list.remove_class('bar')
95
- @list.each { |e| assert_equal 'foo', e['class'] }
96
- end
97
-
98
- def test_remove_class_completely
99
- @list.each { |e| e['class'] = 'foo' }
100
-
101
- assert_equal @list, @list.remove_class
102
- @list.each { |e| assert_nil e['class'] }
103
- end
104
-
105
- def test_attribute_set
106
- @list.each { |e| assert_nil e['foo'] }
107
-
108
- [ ['attribute', 'bar'], ['attr', 'biz'], ['set', 'baz'] ].each do |t|
109
- @list.send(t.first.to_sym, 'foo', t.last)
110
- @list.each { |e| assert_equal t.last, e['foo'] }
111
- end
112
- end
113
-
114
- def test_attribute_set_with_block
115
- @list.each { |e| assert_nil e['foo'] }
116
-
117
- [ ['attribute', 'bar'], ['attr', 'biz'], ['set', 'baz'] ].each do |t|
118
- @list.send(t.first.to_sym, 'foo') { |x| t.last }
119
- @list.each { |e| assert_equal t.last, e['foo'] }
120
- end
121
- end
122
-
123
- def test_attribute_set_with_hash
124
- @list.each { |e| assert_nil e['foo'] }
125
-
126
- [ ['attribute', 'bar'], ['attr', 'biz'], ['set', 'baz'] ].each do |t|
127
- @list.send(t.first.to_sym, 'foo' => t.last)
128
- @list.each { |e| assert_equal t.last, e['foo'] }
129
- end
130
- end
131
-
132
- def test_attribute_no_args
133
- @list.first['foo'] = 'bar'
134
- assert_equal @list.first.attribute('foo'), @list.attribute('foo')
135
- end
136
-
137
- def test_search_empty_node_set
138
- set = Nokogiri::XML::NodeSet.new(Nokogiri::XML::Document.new)
139
- assert_equal 0, set.css('foo').length
140
- assert_equal 0, set.xpath('.//foo').length
141
- assert_equal 0, set.search('foo').length
142
- end
143
-
144
- def test_node_set_search_with_multiple_queries
145
- xml = '<document>
146
- <thing>
147
- <div class="title">important thing</div>
148
- </thing>
149
- <thing>
150
- <div class="content">stuff</div>
151
- </thing>
152
- <thing>
153
- <p class="blah">more stuff</div>
154
- </thing>
155
- </document>'
156
- set = Nokogiri::XML(xml).xpath(".//thing")
157
- assert_kind_of Nokogiri::XML::NodeSet, set
158
-
159
- assert_equal 3, set.xpath('./div', './p').length
160
- assert_equal 3, set.css('.title', '.content', 'p').length
161
- assert_equal 3, set.search('./div', 'p.blah').length
162
- end
163
-
164
- def test_search_with_custom_selector
165
- set = @xml.xpath('//staff')
166
-
167
- [
168
- [:xpath, '//*[awesome(.)]'],
169
- [:search, '//*[awesome(.)]'],
170
- [:css, '*:awesome'],
171
- [:search, '*:awesome']
172
- ].each do |method, query|
173
- custom_employees = set.send(method, query, Class.new {
174
- def awesome ns
175
- ns.select { |n| n.name == 'employee' }
176
- end
177
- }.new)
178
-
179
- assert_equal(@xml.xpath('//employee'), custom_employees,
180
- "using #{method} with custom selector '#{query}'")
181
- end
182
- end
183
-
184
- def test_search_with_variable_bindings
185
- set = @xml.xpath('//staff')
186
-
187
- assert_equal(4, set.xpath('//address[@domestic=$value]', nil, :value => 'Yes').length,
188
- "using #xpath with variable binding")
189
-
190
- assert_equal(4, set.search('//address[@domestic=$value]', nil, :value => 'Yes').length,
191
- "using #search with variable binding")
192
- end
193
-
194
- def test_search_self
195
- set = @xml.xpath('//staff')
196
- assert_equal set.to_a, set.search('.').to_a
197
- end
198
-
199
- def test_css_searches_match_self
200
- html = Nokogiri::HTML("<html><body><div class='a'></div></body></html>")
201
- set = html.xpath("/html/body/div")
202
- assert_equal set.first, set.css(".a").first
203
- assert_equal set.first, set.search(".a").first
204
- end
205
-
206
- def test_css_search_with_namespace
207
- fragment = Nokogiri::XML.fragment(<<-eoxml)
208
- <html xmlns="http://www.w3.org/1999/xhtml">
209
- <head></head>
210
- <body></body>
211
- </html>
212
- eoxml
213
- assert fragment.children.search( 'body', { 'xmlns' => 'http://www.w3.org/1999/xhtml' })
214
- end
215
-
216
- def test_double_equal
217
- assert node_set_one = @xml.xpath('//employee')
218
- assert node_set_two = @xml.xpath('//employee')
219
-
220
- assert_not_equal node_set_one.object_id, node_set_two.object_id
221
-
222
- assert_equal node_set_one, node_set_two
223
- end
224
-
225
- def test_node_set_not_equal_to_string
226
- node_set_one = @xml.xpath('//employee')
227
- assert_not_equal node_set_one, "asdfadsf"
228
- end
229
-
230
- def test_out_of_order_not_equal
231
- one = @xml.xpath('//employee')
232
- two = @xml.xpath('//employee')
233
- two.push two.shift
234
- assert_not_equal one, two
235
- end
236
-
237
- def test_shorter_is_not_equal
238
- node_set_one = @xml.xpath('//employee')
239
- node_set_two = @xml.xpath('//employee')
240
- node_set_two.delete(node_set_two.first)
241
-
242
- assert_not_equal node_set_one, node_set_two
243
- end
244
-
245
- def test_pop
246
- set = @xml.xpath('//employee')
247
- last = set.last
248
- assert_equal last, set.pop
249
- end
250
-
251
- def test_shift
252
- set = @xml.xpath('//employee')
253
- first = set.first
254
- assert_equal first, set.shift
255
- end
256
-
257
- def test_shift_empty
258
- set = Nokogiri::XML::NodeSet.new(@xml)
259
- assert_nil set.shift
260
- end
261
-
262
- def test_pop_empty
263
- set = Nokogiri::XML::NodeSet.new(@xml)
264
- assert_nil set.pop
265
- end
266
-
267
- def test_first_takes_arguments
268
- assert node_set = @xml.xpath('//employee')
269
- assert_equal 2, node_set.first(2).length
270
- end
271
-
272
- def test_first_clamps_arguments
273
- assert node_set = @xml.xpath('//employee[position() < 3]')
274
- assert_equal 2, node_set.first(5).length
275
- end
276
-
277
- [:dup, :clone].each do |method_name|
278
- define_method "test_#{method_name}" do
279
- assert node_set = @xml.xpath('//employee')
280
- duplicate = node_set.send(method_name)
281
- assert_equal node_set.length, duplicate.length
282
- node_set.zip(duplicate).each do |a,b|
283
- assert_equal a, b
284
- end
285
- end
286
- end
287
-
288
- def test_dup_on_empty_set
289
- empty_set = Nokogiri::XML::NodeSet.new @xml, []
290
- assert_equal 0, empty_set.dup.length # this shouldn't raise null pointer exception
291
- end
292
-
293
- def test_xmlns_is_automatically_registered
294
- doc = Nokogiri::XML(<<-eoxml)
295
- <root xmlns="http://tenderlovemaking.com/">
296
- <foo>
297
- <bar/>
298
- </foo>
299
- </root>
300
- eoxml
301
- set = doc.css('foo')
302
- assert_equal 1, set.css('xmlns|bar').length
303
- assert_equal 0, set.css('|bar').length
304
- assert_equal 1, set.xpath('//xmlns:bar').length
305
- assert_equal 1, set.search('xmlns|bar').length
306
- assert_equal 1, set.search('//xmlns:bar').length
307
- assert set.at('//xmlns:bar')
308
- assert set.at('xmlns|bar')
309
- assert set.at('bar')
310
- end
311
-
312
- def test_children_has_document
313
- set = @xml.root.children
314
- assert_instance_of(NodeSet, set)
315
- assert_equal @xml, set.document
316
- end
317
-
318
- def test_length_size
319
- assert node_set = @xml.search('//employee')
320
- assert_equal node_set.length, node_set.size
321
- end
322
-
323
- def test_to_xml
324
- assert node_set = @xml.search('//employee')
325
- assert node_set.to_xml
326
- end
327
-
328
- def test_inner_html
329
- doc = Nokogiri::HTML(<<-eohtml)
330
- <html>
331
- <body>
332
- <div>
333
- <a>one</a>
334
- </div>
335
- <div>
336
- <a>two</a>
337
- </div>
338
- </body>
339
- </html>
340
- eohtml
341
- assert html = doc.css('div').inner_html
342
- assert_match '<a>', html
343
- end
344
-
345
- def test_gt_string_arg
346
- assert node_set = @xml.search('//employee')
347
- assert_equal node_set.xpath('./employeeId'), (node_set > 'employeeId')
348
- end
349
-
350
- def test_at_performs_a_search_with_css
351
- assert node_set = @xml.search('//employee')
352
- assert_equal node_set.first.first_element_child, node_set.at('employeeId')
353
- assert_equal node_set.first.first_element_child, node_set.%('employeeId')
354
- end
355
-
356
- def test_at_performs_a_search_with_xpath
357
- assert node_set = @xml.search('//employee')
358
- assert_equal node_set.first.first_element_child, node_set.at('./employeeId')
359
- assert_equal node_set.first.first_element_child, node_set.%('./employeeId')
360
- end
361
-
362
- def test_at_with_integer_index
363
- assert node_set = @xml.search('//employee')
364
- assert_equal node_set.first, node_set.at(0)
365
- assert_equal node_set.first, node_set % 0
366
- end
367
-
368
- def test_at_xpath
369
- assert node_set = @xml.search('//employee')
370
- assert_equal node_set.first.first_element_child, node_set.at_xpath('./employeeId')
371
- end
372
-
373
- def test_at_css
374
- assert node_set = @xml.search('//employee')
375
- assert_equal node_set.first.first_element_child, node_set.at_css('employeeId')
376
- end
377
-
378
- def test_to_ary
379
- assert node_set = @xml.search('//employee')
380
- foo = []
381
- foo += node_set
382
- assert_equal node_set.length, foo.length
383
- end
384
-
385
- def test_push
386
- node = Nokogiri::XML::Node.new('foo', @xml)
387
- node.content = 'bar'
388
-
389
- assert node_set = @xml.search('//employee')
390
- node_set.push(node)
391
-
392
- assert node_set.include?(node)
393
- end
394
-
395
- def test_delete_with_invalid_argument
396
- employees = @xml.search("//employee")
397
- positions = @xml.search("//position")
398
-
399
- assert_raises(ArgumentError) { employees.delete(positions) }
400
- end
401
-
402
- def test_delete_when_present
403
- employees = @xml.search("//employee")
404
- wally = employees.first
405
- assert employees.include?(wally) # testing setup
406
- length = employees.length
407
-
408
- result = employees.delete(wally)
409
- assert_equal result, wally
410
- assert ! employees.include?(wally)
411
- assert length-1, employees.length
412
- end
413
-
414
- def test_delete_when_not_present
415
- employees = @xml.search("//employee")
416
- phb = @xml.search("//position").first
417
- assert ! employees.include?(phb) # testing setup
418
- length = employees.length
419
-
420
- result = employees.delete(phb)
421
- assert_nil result
422
- assert length, employees.length
423
- end
424
-
425
- def test_delete_on_empty_set
426
- empty_set = Nokogiri::XML::NodeSet.new @xml, []
427
- employee = @xml.at_xpath("//employee")
428
- assert_nil empty_set.delete(employee)
429
- end
430
-
431
- def test_unlink
432
- xml = Nokogiri::XML.parse(<<-eoxml)
433
- <root>
434
- <a class='foo bar'>Bar</a>
435
- <a class='bar foo'>Bar</a>
436
- <a class='bar'>Bar</a>
437
- <a>Hello world</a>
438
- <a class='baz bar foo'>Bar</a>
439
- <a class='bazbarfoo'>Awesome</a>
440
- <a class='bazbar'>Awesome</a>
441
- </root>
442
- eoxml
443
- set = xml.xpath('//a')
444
- set.unlink
445
- set.each do |node|
446
- assert !node.parent
447
- #assert !node.document
448
- assert !node.previous_sibling
449
- assert !node.next_sibling
450
- end
451
- assert_no_match(/Hello world/, xml.to_s)
452
- end
453
-
454
- def test_nodeset_search_takes_namespace
455
- @xml = Nokogiri::XML.parse(<<-eoxml)
456
- <root>
457
- <car xmlns:part="http://general-motors.com/">
458
- <part:tire>Michelin Model XGV</part:tire>
459
- </car>
460
- <bicycle xmlns:part="http://schwinn.com/">
461
- <part:tire>I'm a bicycle tire!</part:tire>
462
- </bicycle>
463
- </root>
464
- eoxml
465
- set = @xml/'root'
466
- assert_equal 1, set.length
467
- bike_tire = set.search('//bike:tire', 'bike' => "http://schwinn.com/")
468
- assert_equal 1, bike_tire.length
469
- end
470
-
471
- def test_new_nodeset
472
- node_set = Nokogiri::XML::NodeSet.new(@xml)
473
- assert_equal(0, node_set.length)
474
- node = Nokogiri::XML::Node.new('form', @xml)
475
- node_set << node
476
- assert_equal(1, node_set.length)
477
- assert_equal(node, node_set.last)
478
- end
479
-
480
- def test_search_on_nodeset
481
- assert node_set = @xml.search('//employee')
482
- assert sub_set = node_set.search('.//name')
483
- assert_equal(node_set.length, sub_set.length)
484
- end
485
-
486
- def test_negative_index_works
487
- assert node_set = @xml.search('//employee')
488
- assert_equal node_set.last, node_set[-1]
489
- end
490
-
491
- def test_large_negative_index_returns_nil
492
- assert node_set = @xml.search('//employee')
493
- assert_nil(node_set[-1 * (node_set.length + 1)])
494
- end
495
-
496
- def test_node_set_fetches_private_data
497
- assert node_set = @xml.search('//employee')
498
-
499
- set = node_set
500
- assert_equal(set[0], set[0])
501
- end
502
-
503
- def test_node_set_returns_0
504
- assert node_set = @xml.search('//asdkfjhasdlkfjhaldskfh')
505
- assert_equal(0, node_set.length)
506
- end
507
-
508
- def test_wrap
509
- employees = (@xml/"//employee").wrap("<wrapper/>")
510
- assert_equal 'wrapper', employees[0].parent.name
511
- assert_equal 'employee', @xml.search("//wrapper").first.children[0].name
512
- end
513
-
514
- def test_wrap_a_fragment
515
- frag = Nokogiri::XML::DocumentFragment.parse <<-EOXML
516
- <employees>
517
- <employee>hello</employee>
518
- <employee>goodbye</employee>
519
- </employees>
520
- EOXML
521
- employees = frag.xpath ".//employee"
522
- employees.wrap("<wrapper/>")
523
- assert_equal 'wrapper', employees[0].parent.name
524
- assert_equal 'employee', frag.at(".//wrapper").children.first.name
525
- end
526
-
527
- def test_wrap_preserves_document_structure
528
- assert_equal "employeeId",
529
- @xml.at_xpath("//employee").children.detect{|j| ! j.text? }.name
530
- @xml.xpath("//employeeId[text()='EMP0001']").wrap("<wrapper/>")
531
- assert_equal "wrapper",
532
- @xml.at_xpath("//employee").children.detect{|j| ! j.text? }.name
533
- end
534
-
535
- def test_plus_operator
536
- names = @xml.search("name")
537
- positions = @xml.search("position")
538
-
539
- names_len = names.length
540
- positions_len = positions.length
541
-
542
- assert_raises(ArgumentError) { names + positions.first }
543
-
544
- result = names + positions
545
- assert_equal names_len, names.length
546
- assert_equal positions_len, positions.length
547
- assert_equal names.length + positions.length, result.length
548
-
549
- names += positions
550
- assert_equal result.length, names.length
551
- end
552
-
553
- def test_union
554
- names = @xml.search("name")
555
-
556
- assert_equal(names.length, (names | @xml.search("name")).length)
557
- end
558
-
559
- def test_minus_operator
560
- employees = @xml.search("//employee")
561
- females = @xml.search("//employee[gender[text()='Female']]")
562
-
563
- employees_len = employees.length
564
- females_len = females.length
565
-
566
- assert_raises(ArgumentError) { employees - females.first }
567
-
568
- result = employees - females
569
- assert_equal employees_len, employees.length
570
- assert_equal females_len, females.length
571
- assert_equal employees.length - females.length, result.length
572
-
573
- employees -= females
574
- assert_equal result.length, employees.length
575
- end
576
-
577
- def test_array_index
578
- employees = @xml.search("//employee")
579
- other = @xml.search("//position").first
580
-
581
- assert_equal 3, employees.index(employees[3])
582
- assert_nil employees.index(other)
583
- assert_equal 3, employees.index {|employee| employee.search("employeeId/text()").to_s == "EMP0004" }
584
- assert_nil employees.index {|employee| employee.search("employeeId/text()").to_s == "EMP0000" }
585
- end
586
-
587
- def test_slice_too_far
588
- employees = @xml.search("//employee")
589
- assert_equal employees.length, employees[0, employees.length + 1].length
590
- assert_equal employees.length, employees[0, employees.length].length
591
- end
592
-
593
- def test_slice_on_empty_node_set
594
- empty_set = Nokogiri::XML::NodeSet.new @xml, []
595
- assert_nil empty_set[99]
596
- assert_nil empty_set[99..101]
597
- assert_nil empty_set[99,2]
598
- end
599
-
600
- def test_slice_waaaaaay_off_the_end
601
- xml = Nokogiri::XML::Builder.new {
602
- root { 100.times { div } }
603
- }.doc
604
- nodes = xml.css "div"
605
- assert_equal 1, nodes.slice(99, 100_000).length
606
- assert_equal 0, nodes.slice(100, 100_000).length
607
- end
608
-
609
- def test_array_slice_with_start_and_end
610
- employees = @xml.search("//employee")
611
- assert_equal [employees[1], employees[2], employees[3]], employees[1,3].to_a
612
- end
613
-
614
- def test_array_index_bracket_equivalence
615
- employees = @xml.search("//employee")
616
- assert_equal [employees[1], employees[2], employees[3]], employees[1,3].to_a
617
- assert_equal [employees[1], employees[2], employees[3]], employees.slice(1,3).to_a
618
- end
619
-
620
- def test_array_slice_with_negative_start
621
- employees = @xml.search("//employee")
622
- assert_equal [employees[2]], employees[-3,1].to_a
623
- assert_equal [employees[2], employees[3]], employees[-3,2].to_a
624
- end
625
-
626
- def test_array_slice_with_invalid_args
627
- employees = @xml.search("//employee")
628
- assert_nil employees[99, 1] # large start
629
- assert_nil employees[1, -1] # negative len
630
- assert_equal [], employees[1, 0].to_a # zero len
631
- end
632
-
633
- def test_array_slice_with_range
634
- employees = @xml.search("//employee")
635
- assert_equal [employees[1], employees[2], employees[3]], employees[1..3].to_a
636
- assert_equal [employees[0], employees[1], employees[2], employees[3]], employees[0..3].to_a
637
- end
638
-
639
- def test_intersection_with_no_overlap
640
- employees = @xml.search("//employee")
641
- positions = @xml.search("//position")
642
-
643
- assert_equal [], (employees & positions).to_a
644
- end
645
-
646
- def test_intersection
647
- employees = @xml.search("//employee")
648
- first_set = employees[0..2]
649
- second_set = employees[2..4]
650
-
651
- assert_equal [employees[2]], (first_set & second_set).to_a
652
- end
653
-
654
- def test_intersection_on_empty_set
655
- empty_set = Nokogiri::XML::NodeSet.new @xml
656
- employees = @xml.search("//employee")
657
- assert_equal 0, (empty_set & employees).length
658
- end
659
-
660
- def test_include?
661
- employees = @xml.search("//employee")
662
- yes = employees.first
663
- no = @xml.search("//position").first
664
-
665
- assert employees.include?(yes)
666
- assert ! employees.include?(no)
667
- end
668
-
669
- def test_include_on_empty_node_set
670
- empty_set = Nokogiri::XML::NodeSet.new @xml, []
671
- employee = @xml.at_xpath("//employee")
672
- assert ! empty_set.include?(employee)
673
- end
674
-
675
- def test_each
676
- employees = @xml.search("//employee")
677
- enum = employees.each
678
- assert_instance_of Enumerator, enum
679
- assert_equal enum.next, employees[0]
680
- assert_equal enum.next, employees[1]
681
- end
682
-
683
- def test_children
684
- employees = @xml.search("//employee")
685
- count = 0
686
- employees.each do |employee|
687
- count += employee.children.length
688
- end
689
- set = employees.children
690
- assert_equal count, set.length
691
- end
692
-
693
- def test_inspect
694
- employees = @xml.search("//employee")
695
- inspected = employees.inspect
696
-
697
- assert_equal "[#{employees.map(&:inspect).join(', ')}]",
698
- inspected
699
- end
700
-
701
- def test_should_not_splode_when_accessing_namespace_declarations_in_a_node_set
702
- 2.times do
703
- xml = Nokogiri::XML "<foo></foo>"
704
- node_set = xml.xpath("//namespace::*")
705
- assert_equal 1, node_set.size
706
- node = node_set.first
707
- node.to_s # segfaults in 1.4.0 and earlier
708
-
709
- # if we haven't segfaulted, let's make sure we handled it correctly
710
- assert_instance_of Nokogiri::XML::Namespace, node
711
- end
712
- end
713
-
714
- def test_should_not_splode_when_arrayifying_node_set_containing_namespace_declarations
715
- xml = Nokogiri::XML "<foo></foo>"
716
- node_set = xml.xpath("//namespace::*")
717
- assert_equal 1, node_set.size
718
-
719
- node_array = node_set.to_a
720
- node = node_array.first
721
- node.to_s # segfaults in 1.4.0 and earlier
722
-
723
- # if we haven't segfaulted, let's make sure we handled it correctly
724
- assert_instance_of Nokogiri::XML::Namespace, node
725
- end
726
-
727
- def test_should_not_splode_when_unlinking_node_set_containing_namespace_declarations
728
- xml = Nokogiri::XML "<foo></foo>"
729
- node_set = xml.xpath("//namespace::*")
730
- assert_equal 1, node_set.size
731
-
732
- node_set.unlink
733
- end
734
-
735
- def test_reverse
736
- xml = Nokogiri::XML "<root><a />b<c />d<e /></root>"
737
- children = xml.root.children
738
- assert_instance_of Nokogiri::XML::NodeSet, children
739
-
740
- reversed = children.reverse
741
- assert_equal reversed[0], children[4]
742
- assert_equal reversed[1], children[3]
743
- assert_equal reversed[2], children[2]
744
- assert_equal reversed[3], children[1]
745
- assert_equal reversed[4], children[0]
746
-
747
- assert_equal children, children.reverse.reverse
748
- end
749
-
750
- def test_node_set_dup_result_has_document_and_is_decorated
751
- x = Module.new do
752
- def awesome! ; end
753
- end
754
- util_decorate(@xml, x)
755
- node_set = @xml.css("address")
756
- new_set = node_set.dup
757
- assert_equal node_set.document, new_set.document
758
- assert new_set.respond_to?(:awesome!)
759
- end
760
-
761
- def test_node_set_union_result_has_document_and_is_decorated
762
- x = Module.new do
763
- def awesome! ; end
764
- end
765
- util_decorate(@xml, x)
766
- node_set1 = @xml.css("address")
767
- node_set2 = @xml.css("address")
768
- new_set = node_set1 | node_set2
769
- assert_equal node_set1.document, new_set.document
770
- assert new_set.respond_to?(:awesome!)
771
- end
772
-
773
- def test_node_set_intersection_result_has_document_and_is_decorated
774
- x = Module.new do
775
- def awesome! ; end
776
- end
777
- util_decorate(@xml, x)
778
- node_set1 = @xml.css("address")
779
- node_set2 = @xml.css("address")
780
- new_set = node_set1 & node_set2
781
- assert_equal node_set1.document, new_set.document
782
- assert new_set.respond_to?(:awesome!)
783
- end
784
-
785
- def test_node_set_difference_result_has_document_and_is_decorated
786
- x = Module.new do
787
- def awesome! ; end
788
- end
789
- util_decorate(@xml, x)
790
- node_set1 = @xml.css("address")
791
- node_set2 = @xml.css("address")
792
- new_set = node_set1 - node_set2
793
- assert_equal node_set1.document, new_set.document
794
- assert new_set.respond_to?(:awesome!)
795
- end
796
-
797
- def test_node_set_slice_result_has_document_and_is_decorated
798
- x = Module.new do
799
- def awesome! ; end
800
- end
801
- util_decorate(@xml, x)
802
- node_set = @xml.css("address")
803
- new_set = node_set[0..-1]
804
- assert_equal node_set.document, new_set.document
805
- assert new_set.respond_to?(:awesome!)
806
- end
807
- end
808
- end
809
- end