libxml-ruby 3.1.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY +8 -0
  3. data/ext/libxml/extconf.h +3 -0
  4. data/ext/libxml/extconf.rb +30 -26
  5. data/ext/libxml/ruby_libxml.h +0 -8
  6. data/ext/libxml/ruby_xml.c +40 -0
  7. data/ext/libxml/ruby_xml_document.c +1 -1
  8. data/ext/libxml/ruby_xml_dtd.c +6 -8
  9. data/ext/libxml/ruby_xml_node.c +1 -1
  10. data/ext/libxml/ruby_xml_parser_context.c +1 -1
  11. data/ext/libxml/ruby_xml_version.h +3 -3
  12. data/lib/libxml-ruby.rb +30 -0
  13. data/lib/libxml.rb +3 -28
  14. data/libxml-ruby.gemspec +2 -2
  15. data/test/test_attr.rb +18 -18
  16. data/test/test_attr_decl.rb +8 -8
  17. data/test/test_attributes.rb +10 -10
  18. data/test/test_canonicalize.rb +16 -24
  19. data/test/test_deprecated_require.rb +3 -3
  20. data/test/test_document.rb +118 -112
  21. data/test/test_document_write.rb +39 -88
  22. data/test/test_dtd.rb +23 -23
  23. data/test/test_encoding.rb +15 -15
  24. data/test/test_encoding_sax.rb +3 -3
  25. data/test/test_error.rb +51 -51
  26. data/test/test_helper.rb +2 -9
  27. data/test/test_html_parser.rb +30 -30
  28. data/test/test_html_parser_context.rb +6 -6
  29. data/test/test_namespace.rb +16 -16
  30. data/test/test_namespaces.rb +25 -25
  31. data/test/test_node.rb +36 -30
  32. data/test/test_node_cdata.rb +10 -10
  33. data/test/test_node_comment.rb +6 -6
  34. data/test/test_node_copy.rb +2 -2
  35. data/test/test_node_edit.rb +16 -16
  36. data/test/test_node_pi.rb +7 -7
  37. data/test/test_node_text.rb +6 -6
  38. data/test/test_node_write.rb +16 -26
  39. data/test/test_node_xlink.rb +6 -6
  40. data/test/test_parser.rb +68 -72
  41. data/test/test_parser_context.rb +28 -28
  42. data/test/test_properties.rb +5 -5
  43. data/test/test_reader.rb +80 -85
  44. data/test/test_relaxng.rb +11 -11
  45. data/test/test_sax_parser.rb +28 -28
  46. data/test/test_schema.rb +24 -24
  47. data/test/test_suite.rb +3 -4
  48. data/test/test_traversal.rb +4 -4
  49. data/test/test_writer.rb +50 -52
  50. data/test/test_xinclude.rb +3 -3
  51. data/test/test_xml.rb +114 -102
  52. data/test/test_xpath.rb +22 -22
  53. data/test/test_xpath_context.rb +5 -5
  54. data/test/test_xpath_expression.rb +6 -6
  55. data/test/test_xpointer.rb +15 -15
  56. metadata +6 -5
@@ -1,23 +1,23 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.expand_path('../test_helper', __FILE__)
3
+ require_relative './test_helper'
4
4
 
5
5
 
6
6
  class TestHtmlParserContext < Minitest::Test
7
7
  def test_default_options
8
- context = XML::HTMLParser::Context.new
8
+ context = LibXML::XML::HTMLParser::Context.new
9
9
  assert_equal(0, context.options)
10
10
  end
11
11
 
12
12
  def test_no_options
13
- context = XML::HTMLParser::Context.new
13
+ context = LibXML::XML::HTMLParser::Context.new
14
14
  context.options = 0
15
15
  assert_equal(0, context.options)
16
16
  end
17
17
 
18
18
  def test_options
19
- context = XML::HTMLParser::Context.new
20
- context.options = XML::HTMLParser::Options::NOERROR
21
- assert_equal(XML::HTMLParser::Options::NOERROR, context.options)
19
+ context = LibXML::XML::HTMLParser::Context.new
20
+ context.options = LibXML::XML::HTMLParser::Options::NOERROR
21
+ assert_equal(LibXML::XML::HTMLParser::Options::NOERROR, context.options)
22
22
  end
23
23
  end
@@ -1,12 +1,12 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.expand_path('../test_helper', __FILE__)
3
+ require_relative './test_helper'
4
4
 
5
5
 
6
6
  class TestNS < Minitest::Test
7
7
  def setup
8
8
  file = File.join(File.dirname(__FILE__), 'model/soap.xml')
9
- @doc = XML::Document.file(file)
9
+ @doc = LibXML::XML::Document.file(file)
10
10
  end
11
11
 
12
12
  def teardown
@@ -14,46 +14,46 @@ class TestNS < Minitest::Test
14
14
  end
15
15
 
16
16
  def test_create_ns
17
- node = XML::Node.new('foo')
18
- ns = XML::Namespace.new(node, 'my_namepace', 'http://www.mynamespace.com')
17
+ node = LibXML::XML::Node.new('foo')
18
+ ns = LibXML::XML::Namespace.new(node, 'my_namepace', 'http://www.mynamespace.com')
19
19
  assert_equal(ns.prefix, 'my_namepace')
20
20
  assert_equal(ns.href, 'http://www.mynamespace.com')
21
21
  end
22
22
 
23
23
  def test_create_default_ns
24
- node = XML::Node.new('foo')
25
- ns = XML::Namespace.new(node, nil, 'http://www.mynamespace.com')
24
+ node = LibXML::XML::Node.new('foo')
25
+ ns = LibXML::XML::Namespace.new(node, nil, 'http://www.mynamespace.com')
26
26
  assert_nil(ns.prefix)
27
27
  assert_equal(ns.href, 'http://www.mynamespace.com')
28
28
  end
29
29
 
30
30
  def test_create_unbound_ns
31
31
  error = assert_raises(TypeError) do
32
- XML::Namespace.new(nil, 'my_namepace', 'http://www.mynamespace.com')
32
+ LibXML::XML::Namespace.new(nil, 'my_namepace', 'http://www.mynamespace.com')
33
33
  end
34
34
  assert_equal('wrong argument type nil (expected Data)', error.to_s)
35
35
  end
36
36
 
37
37
  def test_duplicate_ns
38
- node = XML::Node.new('foo')
39
- XML::Namespace.new(node, 'myname', 'http://www.mynamespace.com')
40
- assert_raises(XML::Error) do
41
- XML::Namespace.new(node, 'myname', 'http://www.mynamespace.com')
38
+ node = LibXML::XML::Node.new('foo')
39
+ LibXML::XML::Namespace.new(node, 'myname', 'http://www.mynamespace.com')
40
+ assert_raises(LibXML::XML::Error) do
41
+ LibXML::XML::Namespace.new(node, 'myname', 'http://www.mynamespace.com')
42
42
  end
43
43
  end
44
44
 
45
45
  def test_eql
46
- node = XML::Node.new('Envelope')
46
+ node = LibXML::XML::Node.new('Envelope')
47
47
 
48
48
  assert(node.namespaces.namespace.eql?(node.namespaces.namespace))
49
49
  end
50
50
 
51
51
  def test_equal
52
- node1 = XML::Node.new('Envelope')
53
- ns1 = XML::Namespace.new(node1, 'soap', 'http://schemas.xmlsoap.org/soap/envelope/')
52
+ node1 = LibXML::XML::Node.new('Envelope')
53
+ ns1 = LibXML::XML::Namespace.new(node1, 'soap', 'http://schemas.xmlsoap.org/soap/envelope/')
54
54
 
55
- node2 = XML::Node.new('Envelope')
56
- ns2 = XML::Namespace.new(node2, 'soap', 'http://schemas.xmlsoap.org/soap/envelope/')
55
+ node2 = LibXML::XML::Node.new('Envelope')
56
+ ns2 = LibXML::XML::Namespace.new(node2, 'soap', 'http://schemas.xmlsoap.org/soap/envelope/')
57
57
 
58
58
  assert(ns1 == ns2)
59
59
  end
@@ -1,12 +1,12 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.expand_path('../test_helper', __FILE__)
3
+ require_relative './test_helper'
4
4
 
5
5
 
6
6
  class TestNamespaces < Minitest::Test
7
7
  def setup
8
8
  file = File.join(File.dirname(__FILE__), 'model/soap.xml')
9
- @doc = XML::Document.file(file)
9
+ @doc = LibXML::XML::Document.file(file)
10
10
  end
11
11
 
12
12
  def teardown
@@ -28,10 +28,10 @@ class TestNamespaces < Minitest::Test
28
28
  end
29
29
 
30
30
  def test_set_namespace_node
31
- node = XML::Node.new('Envelope')
31
+ node = LibXML::XML::Node.new('Envelope')
32
32
  assert_equal('<Envelope/>', node.to_s)
33
33
 
34
- ns = XML::Namespace.new(node, 'soap', 'http://schemas.xmlsoap.org/soap/envelope/')
34
+ ns = LibXML::XML::Namespace.new(node, 'soap', 'http://schemas.xmlsoap.org/soap/envelope/')
35
35
  assert_equal("<Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"/>", node.to_s)
36
36
  assert_nil(node.namespaces.namespace)
37
37
 
@@ -43,16 +43,16 @@ class TestNamespaces < Minitest::Test
43
43
 
44
44
  def test_set_namespace_attribute
45
45
  # Create node
46
- node = XML::Node.new('Envelope')
46
+ node = LibXML::XML::Node.new('Envelope')
47
47
  assert_equal('<Envelope/>', node.to_s)
48
48
 
49
49
  # Create attribute
50
- attr = XML::Attr.new(node, "encodingStyle", "http://www.w3.org/2001/12/soap-encoding")
50
+ attr = LibXML::XML::Attr.new(node, "encodingStyle", "http://www.w3.org/2001/12/soap-encoding")
51
51
  assert_equal('<Envelope encodingStyle="http://www.w3.org/2001/12/soap-encoding"/>',
52
52
  node.to_s)
53
53
 
54
54
  # Create namespace attribute
55
- ns = XML::Namespace.new(node, 'soap', 'http://schemas.xmlsoap.org/soap/envelope/')
55
+ ns = LibXML::XML::Namespace.new(node, 'soap', 'http://schemas.xmlsoap.org/soap/envelope/')
56
56
  assert_equal('<Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" encodingStyle="http://www.w3.org/2001/12/soap-encoding"/>',
57
57
  node.to_s)
58
58
  assert_nil(node.namespaces.namespace)
@@ -71,19 +71,19 @@ class TestNamespaces < Minitest::Test
71
71
  end
72
72
 
73
73
  def test_define_namespace
74
- node = XML::Node.new('Envelope')
74
+ node = LibXML::XML::Node.new('Envelope')
75
75
  assert_equal('<Envelope/>', node.to_s)
76
76
 
77
- XML::Namespace.new(node, 'soap', 'http://schemas.xmlsoap.org/soap/envelope/')
77
+ LibXML::XML::Namespace.new(node, 'soap', 'http://schemas.xmlsoap.org/soap/envelope/')
78
78
  assert_equal("<Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"/>", node.to_s)
79
79
  assert_nil(node.namespaces.namespace)
80
80
  end
81
81
 
82
82
  def test_define_default_namespace
83
- node = XML::Node.new('Envelope')
83
+ node = LibXML::XML::Node.new('Envelope')
84
84
  assert_equal('<Envelope/>', node.to_s)
85
85
 
86
- XML::Namespace.new(node, nil, 'http://schemas.xmlsoap.org/soap/envelope/')
86
+ LibXML::XML::Namespace.new(node, nil, 'http://schemas.xmlsoap.org/soap/envelope/')
87
87
  assert_equal("<Envelope xmlns=\"http://schemas.xmlsoap.org/soap/envelope/\"/>", node.to_s)
88
88
  # This seems wrong, but appears to be the way libxml works
89
89
  assert_nil(node.namespaces.namespace)
@@ -97,27 +97,27 @@ class TestNamespaces < Minitest::Test
97
97
  assert_equal(5, namespaces.length)
98
98
 
99
99
  namespace = namespaces[0]
100
- assert_instance_of(XML::Namespace, namespace)
100
+ assert_instance_of(LibXML::XML::Namespace, namespace)
101
101
  assert_nil(namespace.prefix)
102
102
  assert_equal('http://services.somewhere.com', namespace.href)
103
103
 
104
104
  namespace = namespaces[1]
105
- assert_instance_of(XML::Namespace, namespace)
105
+ assert_instance_of(LibXML::XML::Namespace, namespace)
106
106
  assert_equal('ns1', namespace.prefix)
107
107
  assert_equal('http://domain.somewhere.com', namespace.href)
108
108
 
109
109
  namespace = namespaces[2]
110
- assert_instance_of(XML::Namespace, namespace)
110
+ assert_instance_of(LibXML::XML::Namespace, namespace)
111
111
  assert_equal('soap', namespace.prefix)
112
112
  assert_equal('http://schemas.xmlsoap.org/soap/envelope/', namespace.href)
113
113
 
114
114
  namespace = namespaces[3]
115
- assert_instance_of(XML::Namespace, namespace)
115
+ assert_instance_of(LibXML::XML::Namespace, namespace)
116
116
  assert_equal('xsd', namespace.prefix)
117
117
  assert_equal('http://www.w3.org/2001/XMLSchema', namespace.href)
118
118
 
119
119
  namespace = namespaces[4]
120
- assert_instance_of(XML::Namespace, namespace)
120
+ assert_instance_of(LibXML::XML::Namespace, namespace)
121
121
  assert_equal('xsi', namespace.prefix)
122
122
  assert_equal('http://www.w3.org/2001/XMLSchema-instance', namespace.href)
123
123
  end
@@ -127,17 +127,17 @@ class TestNamespaces < Minitest::Test
127
127
  assert_equal(3, ns_defs.size)
128
128
 
129
129
  namespace = ns_defs[0]
130
- assert_instance_of(XML::Namespace, namespace)
130
+ assert_instance_of(LibXML::XML::Namespace, namespace)
131
131
  assert_equal('soap', namespace.prefix)
132
132
  assert_equal('http://schemas.xmlsoap.org/soap/envelope/', namespace.href)
133
133
 
134
134
  namespace = ns_defs[1]
135
- assert_instance_of(XML::Namespace, namespace)
135
+ assert_instance_of(LibXML::XML::Namespace, namespace)
136
136
  assert_equal('xsd', namespace.prefix)
137
137
  assert_equal('http://www.w3.org/2001/XMLSchema', namespace.href)
138
138
 
139
139
  namespace = ns_defs[2]
140
- assert_instance_of(XML::Namespace, namespace)
140
+ assert_instance_of(LibXML::XML::Namespace, namespace)
141
141
  assert_equal('xsi', namespace.prefix)
142
142
  assert_equal('http://www.w3.org/2001/XMLSchema-instance', namespace.href)
143
143
 
@@ -147,7 +147,7 @@ class TestNamespaces < Minitest::Test
147
147
  assert_equal(1, ns_defs.size)
148
148
 
149
149
  namespace = ns_defs[0]
150
- assert_instance_of(XML::Namespace, namespace)
150
+ assert_instance_of(LibXML::XML::Namespace, namespace)
151
151
  assert_nil(namespace.prefix)
152
152
  assert_equal('http://services.somewhere.com', namespace.href)
153
153
  end
@@ -155,7 +155,7 @@ class TestNamespaces < Minitest::Test
155
155
  def test_find_by_prefix
156
156
  namespace = @doc.root.namespaces.find_by_prefix('soap')
157
157
 
158
- assert_instance_of(XML::Namespace, namespace)
158
+ assert_instance_of(LibXML::XML::Namespace, namespace)
159
159
  assert_equal('soap', namespace.prefix)
160
160
  assert_equal('http://schemas.xmlsoap.org/soap/envelope/', namespace.href)
161
161
  end
@@ -168,7 +168,7 @@ class TestNamespaces < Minitest::Test
168
168
  :ns1 => 'http://services.somewhere.com')
169
169
  namespace = node.namespaces.find_by_prefix(nil)
170
170
 
171
- assert_instance_of(XML::Namespace, namespace)
171
+ assert_instance_of(LibXML::XML::Namespace, namespace)
172
172
  assert_nil(namespace.prefix)
173
173
  assert_equal('http://services.somewhere.com', namespace.href)
174
174
  end
@@ -179,19 +179,19 @@ class TestNamespaces < Minitest::Test
179
179
 
180
180
  namespace = node.namespaces.find_by_href('http://schemas.xmlsoap.org/soap/envelope/')
181
181
 
182
- assert_instance_of(XML::Namespace, namespace)
182
+ assert_instance_of(LibXML::XML::Namespace, namespace)
183
183
  assert_equal('soap', namespace.prefix)
184
184
  assert_equal('http://schemas.xmlsoap.org/soap/envelope/', namespace.href)
185
185
  end
186
186
 
187
187
  def test_default_namespace
188
- doc = XML::Document.string('<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"/>')
188
+ doc = LibXML::XML::Document.string('<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"/>')
189
189
  ns = doc.root.namespaces.default
190
190
  assert_equal(ns.href, 'http://schemas.xmlsoap.org/soap/envelope/')
191
191
  end
192
192
 
193
193
  def test_default_prefix
194
- doc = XML::Document.string('<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"/>')
194
+ doc = LibXML::XML::Document.string('<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"/>')
195
195
  doc.root.namespaces.default_prefix = 'soap'
196
196
 
197
197
  node = doc.root.find_first('/soap:Envelope')
@@ -1,19 +1,19 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.expand_path('../test_helper', __FILE__)
3
+ require_relative './test_helper'
4
4
 
5
5
  class TestNode < Minitest::Test
6
6
  def setup
7
7
  @file_name = "model/bands.utf-8.xml"
8
8
 
9
9
  # Strip spaces to make testing easier
10
- XML.default_keep_blanks = false
10
+ LibXML::XML.default_keep_blanks = false
11
11
  file = File.join(File.dirname(__FILE__), @file_name)
12
- @doc = XML::Document.file(file)
12
+ @doc = LibXML::XML::Document.file(file)
13
13
  end
14
14
 
15
15
  def teardown
16
- XML.default_keep_blanks = true
16
+ LibXML::XML.default_keep_blanks = true
17
17
  @doc = nil
18
18
  end
19
19
 
@@ -23,52 +23,48 @@ class TestNode < Minitest::Test
23
23
  end
24
24
 
25
25
  def test_doc_class
26
- assert_instance_of(XML::Document, @doc)
26
+ assert_instance_of(LibXML::XML::Document, @doc)
27
27
  end
28
28
 
29
29
  def test_doc_node_type
30
- assert_equal XML::Node::DOCUMENT_NODE, @doc.node_type
30
+ assert_equal LibXML::XML::Node::DOCUMENT_NODE, @doc.node_type
31
31
  end
32
32
 
33
33
  def test_root_class
34
- assert_instance_of(XML::Node, @doc.root)
34
+ assert_instance_of(LibXML::XML::Node, @doc.root)
35
35
  end
36
36
 
37
37
  def test_root_node_type
38
- assert_equal XML::Node::ELEMENT_NODE, @doc.root.node_type
38
+ assert_equal LibXML::XML::Node::ELEMENT_NODE, @doc.root.node_type
39
39
  end
40
40
 
41
41
  def test_node_class
42
42
  for n in nodes
43
- assert_instance_of(XML::Node, n)
43
+ assert_instance_of(LibXML::XML::Node, n)
44
44
  end
45
45
  end
46
46
 
47
47
  def test_context
48
48
  node = @doc.root
49
49
  context = node.context
50
- assert_instance_of(XML::XPath::Context, context)
50
+ assert_instance_of(LibXML::XML::XPath::Context, context)
51
51
  end
52
52
 
53
53
  def test_find
54
- assert_instance_of(XML::XPath::Object, self.nodes)
54
+ assert_instance_of(LibXML::XML::XPath::Object, self.nodes)
55
55
  end
56
56
 
57
57
  def test_node_child_get
58
58
  assert_instance_of(TrueClass, @doc.root.child?)
59
- assert_instance_of(XML::Node, @doc.root.child)
59
+ assert_instance_of(LibXML::XML::Node, @doc.root.child)
60
60
 
61
- if defined?(Encoding)
62
- assert_equal(Encoding::UTF_8, @doc.root.child.name.encoding)
63
- assert_equal("m\u00F6tley_cr\u00FCe", @doc.root.child.name)
64
- else
65
- assert_equal("m\303\266tley_cr\303\274e", @doc.root.child.name)
66
- end
61
+ assert_equal(Encoding::UTF_8, @doc.root.child.name.encoding)
62
+ assert_equal("m\u00F6tley_cr\u00FCe", @doc.root.child.name)
67
63
  end
68
64
 
69
65
  def test_node_doc
70
66
  for n in nodes
71
- assert_instance_of(XML::Document, n.doc) if n.document?
67
+ assert_instance_of(LibXML::XML::Document, n.doc) if n.document?
72
68
  end
73
69
  end
74
70
 
@@ -80,7 +76,7 @@ class TestNode < Minitest::Test
80
76
  def test_node_find
81
77
  nodes = @doc.root.find('./fixnum')
82
78
  for node in nodes
83
- assert_instance_of(XML::Node, node)
79
+ assert_instance_of(LibXML::XML::Node, node)
84
80
  end
85
81
  end
86
82
 
@@ -96,7 +92,7 @@ class TestNode < Minitest::Test
96
92
  assert(node_a.eql?(node_b))
97
93
 
98
94
  file = File.join(File.dirname(__FILE__), @file_name)
99
- doc2 = XML::Document.file(file)
95
+ doc2 = LibXML::XML::Document.file(file)
100
96
 
101
97
  node_a2 = doc2.find_first('*[@country]')
102
98
 
@@ -107,8 +103,8 @@ class TestNode < Minitest::Test
107
103
  end
108
104
 
109
105
  def test_equality_2
110
- parent = XML::Node.new('parent')
111
- child = XML::Node.new('child')
106
+ parent = LibXML::XML::Node.new('parent')
107
+ child = LibXML::XML::Node.new('child')
112
108
  parent << child
113
109
 
114
110
  node_a = child.parent
@@ -139,7 +135,7 @@ class TestNode < Minitest::Test
139
135
  end
140
136
 
141
137
  def test_base
142
- doc = XML::Parser.string('<person />').parse
138
+ doc = LibXML::XML::Parser.string('<person />').parse
143
139
  assert_nil(doc.root.base_uri)
144
140
  end
145
141
 
@@ -152,7 +148,7 @@ class TestNode < Minitest::Test
152
148
  #
153
149
  def test_output_escaping
154
150
  text = '<bad-script>if (a &lt; b || b &gt; c) { return "text"; }<stop/>return "&gt;&gt;&gt;snip&lt;&lt;&lt;";</bad-script>'
155
- node = XML::Parser.string(text).parse.root
151
+ node = LibXML::XML::Parser.string(text).parse.root
156
152
  assert_equal text, node.to_s
157
153
 
158
154
  text_noenc = '<bad-script>if (a < b || b > c) { return "text"; }<stop/>return ">>>snip<<<";</bad-script>'
@@ -172,7 +168,7 @@ class TestNode < Minitest::Test
172
168
  # Just a sanity check for output escaping.
173
169
  def test_output_escaping_sanity
174
170
  text = '<bad-script>if (a &lt; b || b &gt; c) { return "text"; }<stop/>return "&gt;&gt;&gt;snip&lt;&lt;&lt;";</bad-script>'
175
- node = XML::Parser.string(text).parse.root
171
+ node = LibXML::XML::Parser.string(text).parse.root
176
172
  affected = node.find('//text()')
177
173
 
178
174
  check_escaping = lambda do |flag|
@@ -205,15 +201,15 @@ class TestNode < Minitest::Test
205
201
  node = @doc.root
206
202
 
207
203
  node.space_preserve = false
208
- assert_equal XML::Node::SPACE_DEFAULT, node.space_preserve
204
+ assert_equal LibXML::XML::Node::SPACE_DEFAULT, node.space_preserve
209
205
 
210
206
  node.space_preserve = true
211
- assert_equal XML::Node::SPACE_PRESERVE, node.space_preserve
207
+ assert_equal LibXML::XML::Node::SPACE_PRESERVE, node.space_preserve
212
208
  end
213
209
 
214
210
  def test_empty
215
211
  text = '<name> </name>'
216
- doc = XML::Parser.string(text).parse
212
+ doc = LibXML::XML::Parser.string(text).parse
217
213
 
218
214
  node = doc.root
219
215
  assert(!node.empty?)
@@ -222,8 +218,18 @@ class TestNode < Minitest::Test
222
218
  assert(text_node.empty?)
223
219
  end
224
220
 
221
+ def test_save_no_empty_tags
222
+ node = LibXML::XML::Node.new('test')
223
+ assert_equal '<test/>', node.to_s
224
+
225
+ LibXML::XML.default_save_no_empty_tags = true
226
+ assert_equal '<test></test>', node.to_s
227
+
228
+ LibXML::XML.default_save_no_empty_tags = false
229
+ end
230
+
225
231
  def test_set_content
226
- node = XML::Node.new('test')
232
+ node = LibXML::XML::Node.new('test')
227
233
  node.content = "unescaped & string"
228
234
  assert_equal("unescaped & string", node.content)
229
235
  assert_equal("<test>unescaped &amp; string</test>", node.to_s)