nokogiri 1.3.2-java → 1.3.3-java

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 (66) hide show
  1. data/CHANGELOG.ja.rdoc +25 -4
  2. data/CHANGELOG.rdoc +20 -0
  3. data/Manifest.txt +2 -0
  4. data/Rakefile +20 -21
  5. data/ext/nokogiri/extconf.rb +8 -1
  6. data/ext/nokogiri/html_document.c +0 -2
  7. data/ext/nokogiri/nokogiri.c +2 -0
  8. data/ext/nokogiri/nokogiri.h +3 -4
  9. data/ext/nokogiri/xml_document.c +30 -23
  10. data/ext/nokogiri/xml_document.h +3 -2
  11. data/ext/nokogiri/xml_dtd.c +4 -0
  12. data/ext/nokogiri/xml_dtd.h +2 -0
  13. data/ext/nokogiri/xml_node.c +28 -9
  14. data/ext/nokogiri/xml_reader.c +0 -7
  15. data/ext/nokogiri/xml_relax_ng.c +7 -1
  16. data/ext/nokogiri/xml_sax_parser.c +2 -0
  17. data/lib/action-nokogiri.rb +2 -0
  18. data/lib/nokogiri.rb +9 -3
  19. data/lib/nokogiri/css/generated_tokenizer.rb +80 -82
  20. data/lib/nokogiri/css/tokenizer.rb +1 -5
  21. data/lib/nokogiri/decorators/hpricot/node_set.rb +1 -1
  22. data/lib/nokogiri/ffi/structs/common_node.rb +1 -1
  23. data/lib/nokogiri/ffi/structs/xml_document.rb +1 -1
  24. data/lib/nokogiri/ffi/xml/document.rb +15 -4
  25. data/lib/nokogiri/ffi/xml/node.rb +85 -63
  26. data/lib/nokogiri/ffi/xml/reader.rb +4 -15
  27. data/lib/nokogiri/ffi/xml/relax_ng.rb +3 -1
  28. data/lib/nokogiri/hpricot.rb +30 -0
  29. data/lib/nokogiri/html/document.rb +3 -1
  30. data/lib/nokogiri/html/document_fragment.rb +1 -1
  31. data/lib/nokogiri/html/sax/parser.rb +2 -1
  32. data/lib/nokogiri/version.rb +1 -1
  33. data/lib/nokogiri/xml/builder.rb +44 -1
  34. data/lib/nokogiri/xml/document.rb +8 -1
  35. data/lib/nokogiri/xml/document_fragment.rb +1 -1
  36. data/lib/nokogiri/xml/fragment_handler.rb +4 -7
  37. data/lib/nokogiri/xml/node.rb +9 -6
  38. data/lib/nokogiri/xml/node_set.rb +7 -0
  39. data/lib/nokogiri/xml/parse_options.rb +1 -1
  40. data/test/css/test_nthiness.rb +2 -3
  41. data/test/ffi/test_document.rb +6 -6
  42. data/test/files/2ch.html +108 -0
  43. data/test/files/shift_jis.xml +5 -0
  44. data/test/helper.rb +3 -0
  45. data/test/hpricot/test_alter.rb +9 -9
  46. data/test/hpricot/test_builder.rb +2 -2
  47. data/test/hpricot/test_parser.rb +70 -146
  48. data/test/hpricot/test_paths.rb +2 -2
  49. data/test/hpricot/test_preserved.rb +2 -2
  50. data/test/hpricot/test_xml.rb +3 -3
  51. data/test/html/sax/test_parser.rb +12 -0
  52. data/test/html/test_builder.rb +6 -4
  53. data/test/html/test_document.rb +7 -0
  54. data/test/html/test_document_encoding.rb +17 -0
  55. data/test/html/test_document_fragment.rb +12 -0
  56. data/test/html/test_node.rb +5 -2
  57. data/test/test_convert_xpath.rb +1 -50
  58. data/test/test_css_cache.rb +1 -12
  59. data/test/test_nokogiri.rb +7 -0
  60. data/test/test_reader.rb +14 -0
  61. data/test/xml/test_document.rb +44 -0
  62. data/test/xml/test_document_fragment.rb +12 -0
  63. data/test/xml/test_node.rb +10 -2
  64. data/test/xml/test_node_encoding.rb +23 -0
  65. data/test/xml/test_node_set.rb +10 -0
  66. metadata +5 -3
@@ -5,11 +5,11 @@ class TestParser < Nokogiri::TestCase
5
5
  include Nokogiri
6
6
 
7
7
  def test_roundtrip
8
- @basic = Hpricot.parse(TestFiles::BASIC)
8
+ @basic = Nokogiri.parse(TestFiles::BASIC)
9
9
  %w[link link[2] body #link1 a p.ohmy].each do |css_sel|
10
10
  ele = @basic.at(css_sel)
11
11
  assert_equal ele, @basic.at(ele.css_path), ele.css_path
12
- assert_equal ele, @basic.at(ele.xpath), ele.xpath
12
+ assert_equal ele, @basic.at(ele.path), ele.xpath
13
13
  end
14
14
  end
15
15
  end
@@ -64,10 +64,10 @@ class TestPreserved < Nokogiri::TestCase
64
64
  def test_escaping_of_attrs
65
65
  # ampersands in URLs
66
66
  str = %{<a href="http://google.com/search?q=nokogiri&amp;l=en">Google</a>}
67
- link = (doc = Nokogiri.Hpricot(str)).at(:a)
67
+ link = (doc = Nokogiri(str)).at(:a)
68
68
  assert_equal "http://google.com/search?q=nokogiri&l=en", link['href']
69
69
  assert_equal "http://google.com/search?q=nokogiri&l=en", link.get_attribute('href')
70
- assert_equal "http://google.com/search?q=nokogiri&l=en", link.raw_attributes['href']
70
+ assert_equal "http://google.com/search?q=nokogiri&l=en", link['href']
71
71
  assert_equal str, link.to_html
72
72
 
73
73
  # alter the url
@@ -6,14 +6,14 @@ class TestParser < Nokogiri::TestCase
6
6
  # normally, the link tags are empty HTML tags.
7
7
  # contributed by laudney.
8
8
  def test_normally_empty
9
- doc = Hpricot::XML("<rss><channel><title>this is title</title><link>http://fake.com</link></channel></rss>")
9
+ doc = Nokogiri::XML("<rss><channel><title>this is title</title><link>http://fake.com</link></channel></rss>")
10
10
  assert_equal "this is title", (doc/:rss/:channel/:title).text
11
11
  assert_equal "http://fake.com", (doc/:rss/:channel/:link).text
12
12
  end
13
13
 
14
14
  # make sure XML doesn't get downcased
15
15
  def test_casing
16
- doc = Hpricot::XML(TestFiles::WHY)
16
+ doc = Nokogiri::XML(TestFiles::WHY)
17
17
 
18
18
  ### Modified.
19
19
  # I don't want to differentiate pseudo classes from namespaces. If
@@ -24,7 +24,7 @@ class TestParser < Nokogiri::TestCase
24
24
 
25
25
  # be sure tags named "text" are ok
26
26
  def test_text_tags
27
- doc = Hpricot::XML("<feed><title>City Poisoned</title><text>Rita Lee has poisoned Brazil.</text></feed>")
27
+ doc = Nokogiri::XML("<feed><title>City Poisoned</title><text>Rita Lee has poisoned Brazil.</text></feed>")
28
28
  assert_equal "City Poisoned", (doc/"title").text
29
29
  end
30
30
  end
@@ -9,6 +9,18 @@ module Nokogiri
9
9
  @parser = HTML::SAX::Parser.new(Doc.new)
10
10
  end
11
11
 
12
+ def test_parse_empty_document
13
+ # This caused a segfault in libxml 2.6.x
14
+ assert_nothing_raised { @parser.parse '' }
15
+ end
16
+
17
+ def test_parse_empty_file
18
+ # Make sure empty files don't break stuff
19
+ empty_file_name = File.join(Dir.tmpdir, 'bogus.xml')
20
+ FileUtils.touch empty_file_name
21
+ assert_nothing_raised { @parser.parse_file empty_file_name }
22
+ end
23
+
12
24
  def test_parse_file
13
25
  @parser.parse_file(HTML_FILE)
14
26
  assert_equal 1110, @parser.document.end_elements.length
@@ -47,11 +47,13 @@ module Nokogiri
47
47
 
48
48
  def test_tag_nesting
49
49
  builder = Nokogiri::HTML::Builder.new do
50
- span.left ''
51
- span.middle {
52
- div.icon ''
50
+ body {
51
+ span.left ''
52
+ span.middle {
53
+ div.icon ''
54
+ }
55
+ span.right ''
53
56
  }
54
- span.right ''
55
57
  end
56
58
  assert node = builder.doc.css('span.right').first
57
59
  assert_equal 'middle', node.previous_sibling['class']
@@ -115,6 +115,13 @@ module Nokogiri
115
115
  assert_instance_of Nokogiri::HTML::Document, parent
116
116
  end
117
117
 
118
+ def test_parse_handles_nil_gracefully
119
+ assert_nothing_raised do
120
+ @doc = Nokogiri::HTML::Document.parse(nil)
121
+ end
122
+ assert_instance_of Nokogiri::HTML::Document, @doc
123
+ end
124
+
118
125
  def test_parse_empty_document
119
126
  doc = Nokogiri::HTML("\n")
120
127
  assert_equal 0, doc.css('a').length
@@ -24,6 +24,23 @@ module Nokogiri
24
24
  assert_equal bad_charset.encoding.name, doc.encoding
25
25
  end
26
26
 
27
+ def test_encoding_non_utf8
28
+ orig = '日本語が上手です'
29
+ bin = Encoding::ASCII_8BIT
30
+ [Encoding::Shift_JIS, Encoding::EUC_JP].each do |enc|
31
+ html = <<-eohtml.encode(enc)
32
+ <html>
33
+ <meta http-equiv="Content-Type" content="text/html; charset=#{enc.name}">
34
+ <title xml:lang="ja">#{orig}</title></html>
35
+ eohtml
36
+ text = Nokogiri::HTML.parse(html).at('title').inner_text
37
+ assert_equal(
38
+ orig.encode(enc).force_encoding(bin),
39
+ text.encode(enc).force_encoding(bin)
40
+ )
41
+ end
42
+ end
43
+
27
44
  def test_encoding_with_a_bad_name
28
45
  bad_charset = <<-eohtml
29
46
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@@ -37,6 +37,12 @@ module Nokogiri
37
37
  assert_instance_of klass, fragment
38
38
  end
39
39
 
40
+ def test_subclass_parse
41
+ klass = Class.new(Nokogiri::HTML::DocumentFragment)
42
+ doc = klass.parse("<div>a</div>")
43
+ assert_instance_of klass, doc
44
+ end
45
+
40
46
  def test_html_fragment
41
47
  fragment = Nokogiri::HTML.fragment("<div>a</div>")
42
48
  assert_equal "<div>a</div>", fragment.to_s
@@ -64,6 +70,12 @@ module Nokogiri
64
70
  assert_equal "<div>b</div>", fragment.to_s
65
71
  end
66
72
 
73
+ def test_html_fragment_with_leading_whitespace_and_newline
74
+ doc = " \n<div>b</div> "
75
+ fragment = Nokogiri::HTML::Document.new.fragment(doc)
76
+ assert_equal "<div>b</div>", fragment.to_s
77
+ end
78
+
67
79
  def test_to_s
68
80
  doc = "<span>foo<br></span><span>bar</span>"
69
81
  fragment = Nokogiri::HTML::Document.new.fragment(doc)
@@ -88,8 +88,11 @@ module Nokogiri
88
88
 
89
89
  def test_inner_html=
90
90
  assert div = @html.at('//div')
91
- div.inner_html = '<span>testing</span>'
92
- assert_equal 'span', div.children.first.name
91
+ div.inner_html = '1<span>2</span>3'
92
+ assert_equal '1', div.children[0].to_s
93
+ assert_equal 'span', div.children[1].name
94
+ assert_equal '2', div.children[1].inner_text
95
+ assert_equal '3', div.children[2].to_s
93
96
 
94
97
  div.inner_html = 'testing'
95
98
  assert_equal 'testing', div.content
@@ -1,36 +1,17 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
2
2
 
3
- begin
4
- require 'rubygems'
5
- require 'hpricot'
6
- HAS_HPRICOT = true
7
- rescue LoadError
8
- HAS_HPRICOT = false
9
- end
3
+ require 'rubygems'
10
4
 
11
5
  class TestConvertXPath < Nokogiri::TestCase
12
6
 
13
7
  def setup
14
8
  super
15
9
  @N = Nokogiri(File.read(HTML_FILE))
16
- @NH = Nokogiri.Hpricot(File.read(HTML_FILE)) # decorated document
17
- @H = Hpricot(File.read(HTML_FILE)) if HAS_HPRICOT
18
10
  end
19
11
 
20
12
  def assert_syntactical_equivalence(hpath, xpath, match, &blk)
21
13
  blk ||= lambda {|j| j.first}
22
14
  assert_equal match, blk.call(@N.search(xpath)), "xpath result did not match"
23
- if HAS_HPRICOT
24
- assert_equal match, blk.call(@H.search(hpath)).chomp, "hpath result did not match"
25
- end
26
- assert_equal [xpath], @NH.convert_to_xpath(hpath), "converted hpath did not match xpath"
27
- end
28
-
29
- def test_ordinary_xpath_conversions
30
- assert_equal(".//p", @NH.convert_to_xpath("p").first)
31
- assert_equal(".//p", @NH.convert_to_xpath(:p).first)
32
- assert_equal(".//p", @NH.convert_to_xpath("//p").first)
33
- assert_equal(".//p", @NH.convert_to_xpath(".//p").first)
34
15
  end
35
16
 
36
17
  def test_child_tag
@@ -117,21 +98,6 @@ class TestConvertXPath < Nokogiri::TestCase
117
98
  end
118
99
 
119
100
  def test_positional
120
- ##
121
- # we are intentionally NOT staying compatible with nth-and-friends, as Hpricot has an OB1 bug.
122
- #
123
- # assert_syntactical_equivalence("div > div:eq(0)", ".//div/div[position() = 1]", "\r\nTender Lovemaking\r\nThe act of making love, tenderly.\r\n") do |j|
124
- # j.first.inner_text
125
- # end
126
- # assert_syntactical_equivalence("div/div:eq(0)", ".//div/div[position() = 1]", "\r\nTender Lovemaking\r\nThe act of making love, tenderly.\r\n") do |j|
127
- # j.first.inner_text
128
- # end
129
- # assert_syntactical_equivalence("div/div:nth(0)", ".//div/div[position() = 1]", "\r\nTender Lovemaking\r\nThe act of making love, tenderly.\r\n") do |j|
130
- # j.first.inner_text
131
- # end
132
- # assert_syntactical_equivalence("div/div:nth-of-type(0)", ".//div/div[position() = 1]", "\r\nTender Lovemaking\r\nThe act of making love, tenderly.\r\n") do |j|
133
- # j.first.inner_text
134
- # end
135
101
  assert_syntactical_equivalence("div/div:first()", ".//div/div[position() = 1]", "\r\nTender Lovemaking\r\nThe act of making love, tenderly.\r\n".gsub(/[\r\n]/, '')) do |j|
136
102
  j.first.inner_text.gsub(/[\r\n]/, '')
137
103
  end
@@ -152,21 +118,6 @@ class TestConvertXPath < Nokogiri::TestCase
152
118
  end
153
119
  end
154
120
 
155
- def test_compat_mode_namespaces
156
- assert_equal(".//*[name()='t:sam']", @NH.convert_to_xpath("//t:sam").first)
157
- assert_equal(".//*[name()='t:sam'][@rel='bookmark'][1]", @NH.convert_to_xpath("//t:sam[@rel='bookmark'][1]").first)
158
- end
159
-
160
- ##
161
- # 'and' is not supported by hpricot
162
- # def test_and
163
- # assert_syntactical_equivalence("div[h1 and small]", ".//div[h1 and small]", "\r\nTender Lovemaking\r\nThe act of making love, tenderly.\r\n") do |j|
164
- # j.inner_text
165
- # end
166
- # end
167
-
168
-
169
-
170
121
  # TODO:
171
122
  # doc/'title ~ link' -> links that are siblings of title
172
123
  # doc/'p[@class~="final"]' -> class includes string (whitespacy)
@@ -31,7 +31,7 @@ class TestCssCache < Nokogiri::TestCase
31
31
  times = cache_setting ? 4 : nil
32
32
 
33
33
  Nokogiri::CSS::Parser.set_cache cache_setting
34
-
34
+
35
35
  Nokogiri::CSS.xpath_for(@css)
36
36
  Nokogiri::CSS.xpath_for(@css)
37
37
  Nokogiri::CSS::Parser.new.xpath_for(@css)
@@ -39,17 +39,6 @@ class TestCssCache < Nokogiri::TestCase
39
39
 
40
40
  assert_equal(times, Nokogiri::CSS::Parser.class_eval { @cache.count })
41
41
  end
42
-
43
- define_method "test_hpricot_cache_#{cache_setting ? "true" : "false"}" do
44
- times = cache_setting ? 2 : nil
45
- Nokogiri::CSS::Parser.set_cache cache_setting
46
-
47
- nh = Nokogiri.Hpricot("<html></html>")
48
-
49
- nh.convert_to_xpath(@css)
50
- nh.convert_to_xpath(@css)
51
- assert_equal(times, Nokogiri::CSS::Parser.class_eval { @cache.count })
52
- end
53
42
  end
54
43
 
55
44
 
@@ -30,6 +30,13 @@ class TestNokogiri < Nokogiri::TestCase
30
30
  assert_equal "#{major}.#{minor}.#{bug}", Nokogiri::VERSION_INFO['libxml']['loaded']
31
31
  end
32
32
 
33
+ def test_parse_with_io
34
+ doc = Nokogiri.parse(
35
+ StringIO.new("<html><head><title></title><body></body></html>")
36
+ )
37
+ assert_instance_of Nokogiri::HTML::Document, doc
38
+ end
39
+
33
40
  def test_xml?
34
41
  doc = Nokogiri.parse(File.read(XML_FILE))
35
42
  assert doc.xml?
@@ -313,4 +313,18 @@ class TestReader < Nokogiri::TestCase
313
313
  end
314
314
  assert called
315
315
  end
316
+
317
+ def test_large_document_smoke_test
318
+ # simply run on a large document to verify that there no GC issues
319
+ xml = []
320
+ xml << "<elements>"
321
+ 10000.times { |j| xml << "<element id=\"#{j}\"/>" }
322
+ xml << "</elements>"
323
+ xml = xml.join("\n")
324
+
325
+ Nokogiri::XML::Reader.from_memory(xml).each do |e|
326
+ e.attributes
327
+ end
328
+ end
329
+
316
330
  end
@@ -10,6 +10,37 @@ module Nokogiri
10
10
  @xml = Nokogiri::XML.parse(File.read(XML_FILE), XML_FILE)
11
11
  end
12
12
 
13
+ def test_empty_node_converted_to_html_is_not_self_closing
14
+ doc = Nokogiri::XML('<a></a>')
15
+ assert_equal "<a></a>", doc.inner_html
16
+ end
17
+
18
+ def test_add_child_with_fragment
19
+ doc = Nokogiri::XML::Document.new
20
+ fragment = doc.fragment('<hello />')
21
+ doc.add_child fragment
22
+ assert_equal '/hello', doc.at('//hello').path
23
+ assert_equal 'hello', doc.root.name
24
+ end
25
+
26
+ def test_add_child_with_multiple_roots
27
+ assert_raises(RuntimeError) do
28
+ @xml << Node.new('foo', @xml)
29
+ end
30
+ end
31
+
32
+ def test_move_root_to_document_with_no_root
33
+ sender = Nokogiri::XML('<root>foo</root>')
34
+ newdoc = Nokogiri::XML::Document.new
35
+ newdoc.root = sender.root
36
+ end
37
+
38
+ def test_move_root_with_existing_root_gets_gcd
39
+ doc = Nokogiri::XML('<root>test</root>')
40
+ doc2 = Nokogiri::XML("<root>#{'x' * 5000000}</root>")
41
+ doc2.root = doc.root
42
+ end
43
+
13
44
  def test_validate
14
45
  assert_equal 44, @xml.validate.length
15
46
  end
@@ -35,6 +66,13 @@ module Nokogiri
35
66
  end
36
67
  end
37
68
 
69
+ def test_parse_handles_nil_gracefully
70
+ assert_nothing_raised do
71
+ @doc = Nokogiri::XML::Document.parse(nil)
72
+ end
73
+ assert_instance_of Nokogiri::XML::Document, @doc
74
+ end
75
+
38
76
  def test_parse_takes_block
39
77
  options = nil
40
78
  Nokogiri::XML.parse(File.read(XML_FILE), XML_FILE) do |cfg|
@@ -215,6 +253,12 @@ module Nokogiri
215
253
  assert_raises(Nokogiri::XML::SyntaxError) {
216
254
  Nokogiri::XML('<foo><bar></foo>', nil, nil, 0)
217
255
  }
256
+
257
+ assert_raises(Nokogiri::XML::SyntaxError) {
258
+ Nokogiri::XML('<foo><bar></foo>') { |cfg|
259
+ cfg.strict
260
+ }
261
+ }
218
262
  end
219
263
 
220
264
  def test_XML_function
@@ -37,6 +37,12 @@ module Nokogiri
37
37
  assert_instance_of klass, fragment
38
38
  end
39
39
 
40
+ def test_subclass_parse
41
+ klass = Class.new(Nokogiri::XML::DocumentFragment)
42
+ doc = klass.parse("<div>a</div>")
43
+ assert_instance_of klass, doc
44
+ end
45
+
40
46
  def test_xml_fragment
41
47
  fragment = Nokogiri::XML.fragment("<div>a</div>")
42
48
  assert_equal "<div>a</div>", fragment.to_s
@@ -71,6 +77,12 @@ module Nokogiri
71
77
  fragment = Nokogiri::XML::Document.new.fragment(doc)
72
78
  assert_equal "<div>b</div>", fragment.to_s
73
79
  end
80
+
81
+ def test_xml_fragment_with_leading_whitespace_and_newline
82
+ doc = " \n<div>b</div> "
83
+ fragment = Nokogiri::XML::Document.new.fragment(doc)
84
+ assert_equal "<div>b</div>", fragment.to_s
85
+ end
74
86
  end
75
87
  end
76
88
  end
@@ -114,13 +114,21 @@ module Nokogiri
114
114
  end
115
115
  end
116
116
 
117
+ def test_fragment_creates_elements
118
+ apple = @xml.fragment('<Apple/>')
119
+ apple.children.each do |child|
120
+ assert_equal Nokogiri::XML::Node::ELEMENT_NODE, child.type
121
+ assert_instance_of Nokogiri::XML::Element, child
122
+ end
123
+ end
124
+
117
125
  def test_node_added_to_root_should_get_namespace
118
126
  fruits = Nokogiri::XML(<<-eoxml)
119
127
  <Fruit xmlns='http://www.fruits.org'>
120
128
  </Fruit>
121
129
  eoxml
122
130
  apple = fruits.fragment('<Apple/>')
123
- fruits << apple
131
+ fruits.root << apple
124
132
  assert_equal 1, fruits.xpath('//xmlns:Apple').length
125
133
  end
126
134
 
@@ -364,7 +372,7 @@ module Nokogiri
364
372
  def test_new
365
373
  assert node = Nokogiri::XML::Node.new('input', @xml)
366
374
  assert_equal 1, node.node_type
367
- assert_instance_of Nokogiri::XML::Node, node
375
+ assert_instance_of Nokogiri::XML::Element, node
368
376
  end
369
377
 
370
378
  def test_to_str
@@ -14,6 +14,29 @@ module Nokogiri
14
14
  assert_equal @html.encoding, node['href'].encoding.name
15
15
  end
16
16
 
17
+ def test_text_encoding_is_utf_8
18
+ @html = Nokogiri::HTML(File.open(NICH_FILE))
19
+ assert_equal 'UTF-8', @html.text.encoding.name
20
+ end
21
+
22
+ def test_serialize_encoding_html
23
+ @html = Nokogiri::HTML(File.open(NICH_FILE))
24
+ assert_equal @html.encoding.downcase,
25
+ @html.serialize.encoding.name.downcase
26
+
27
+ @doc = Nokogiri::HTML(@html.serialize)
28
+ assert_equal @html.serialize, @doc.serialize
29
+ end
30
+
31
+ def test_serialize_encoding_xml
32
+ @xml = Nokogiri::XML(File.open(SHIFT_JIS_XML))
33
+ assert_equal @xml.encoding.downcase,
34
+ @xml.serialize.encoding.name.downcase
35
+
36
+ @doc = Nokogiri::XML(@xml.serialize)
37
+ assert_equal @xml.serialize, @doc.serialize
38
+ end
39
+
17
40
  def test_encode_special_chars
18
41
  foo = @html.css('a').first.encode_special_chars('foo')
19
42
  assert_equal @html.encoding, foo.encoding.name