Skip to content

Commit 1d06b4f

Browse files
committed
cleaning up serialize tests
1 parent c534486 commit 1d06b4f

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lib/nokogiri/xml/node.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ def to_xml encoding = nil
392392
def to_xhtml encoding = nil
393393
serialize(encoding, SaveOptions::FORMAT |
394394
SaveOptions::NO_DECLARATION |
395+
SaveOptions::NO_EMPTY_TAGS |
395396
SaveOptions::AS_XHTML)
396397
end
397398

@@ -409,6 +410,7 @@ def write_to io, encoding = nil, save_options = SaveOptions::FORMAT
409410
def write_html_to io, encoding = nil
410411
write_to io, encoding, SaveOptions::FORMAT |
411412
SaveOptions::NO_DECLARATION |
413+
SaveOptions::NO_EMPTY_TAGS |
412414
SaveOptions::AS_HTML
413415
end
414416

@@ -417,6 +419,7 @@ def write_html_to io, encoding = nil
417419
def write_xhtml_to io, encoding = nil
418420
write_to io, encoding, SaveOptions::FORMAT |
419421
SaveOptions::NO_DECLARATION |
422+
SaveOptions::NO_EMPTY_TAGS |
420423
SaveOptions::AS_XHTML
421424
end
422425

test/xml/test_node.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,36 @@ def test_write_to
1919
def test_write_to_with_block
2020
called = false
2121
io = StringIO.new
22+
conf = nil
2223
@xml.write_to io do |config|
2324
called = true
25+
conf = config
2426
config.format.as_html.no_empty_tags
2527
end
2628
io.rewind
2729
assert called
28-
assert_equal @xml.serialize(nil, 1 | 64 | 4), io.read
30+
assert_equal @xml.serialize(nil, conf.options), io.read
2931
end
3032

3133
%w{ xml html xhtml }.each do |type|
3234
define_method(:"test_write_#{type}_to") do
3335
io = StringIO.new
3436
assert @xml.send(:"write_#{type}_to", io)
3537
io.rewind
36-
assert_equal @xml.send(:"to_#{type}"), io.read
38+
assert_match @xml.send(:"to_#{type}"), io.read
3739
end
3840
end
3941

4042
def test_serialize_with_block
4143
called = false
44+
conf = nil
4245
string = @xml.serialize do |config|
4346
called = true
47+
conf = config
4448
config.format.as_html.no_empty_tags
4549
end
4650
assert called
47-
assert_equal @xml.serialize(nil, 1 | 64 | 4), string
51+
assert_equal @xml.serialize(nil, conf.options), string
4852
end
4953

5054
def test_values

0 commit comments

Comments
 (0)