Skip to content

Commit

Permalink
format: clean up html4/test_document.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Sep 23, 2021
1 parent b2645bc commit c4a9de4
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions test/html4/test_document.rb
Expand Up @@ -103,21 +103,21 @@ def test_empty_string_returns_empty_doc
assert_nil(doc.root)
end

unless Nokogiri.uses_libxml?("~> 2.6.0")
def test_to_xhtml_with_indent
doc = Nokogiri::HTML("<html><body><a>foo</a></body></html>")
doc = Nokogiri::HTML(doc.to_xhtml(indent: 2))
assert_indent(2, doc)
end
def test_to_xhtml_with_indent
skip if Nokogiri.uses_libxml?("~> 2.6.0")
doc = Nokogiri::HTML("<html><body><a>foo</a></body></html>")
doc = Nokogiri::HTML(doc.to_xhtml(indent: 2))
assert_indent(2, doc)
end

def test_write_to_xhtml_with_indent
io = StringIO.new
doc = Nokogiri::HTML("<html><body><a>foo</a></body></html>")
doc.write_xhtml_to(io, indent: 5)
io.rewind
doc = Nokogiri::HTML(io.read)
assert_indent(5, doc)
end
def test_write_to_xhtml_with_indent
skip if Nokogiri.uses_libxml?("~> 2.6.0")
io = StringIO.new
doc = Nokogiri::HTML("<html><body><a>foo</a></body></html>")
doc.write_xhtml_to(io, indent: 5)
io.rewind
doc = Nokogiri::HTML(io.read)
assert_indent(5, doc)
end

def test_swap_should_not_exist
Expand Down Expand Up @@ -360,8 +360,10 @@ def test_parse_temp_file
File.open(HTML_FILE, "rb") { |f| temp_html_file.write(f.read) }
temp_html_file.close
temp_html_file.open
assert_equal(Nokogiri::HTML.parse(File.read(HTML_FILE)).xpath("//div/a").length,
Nokogiri::HTML.parse(temp_html_file).xpath("//div/a").length)
assert_equal(
Nokogiri::HTML.parse(File.read(HTML_FILE)).xpath("//div/a").length,
Nokogiri::HTML.parse(temp_html_file).xpath("//div/a").length
)
end

def test_to_xhtml
Expand Down Expand Up @@ -454,8 +456,8 @@ def test_doc_type
assert_equal("-//W3C//DTD XHTML 1.1//EN", html.internal_subset.external_id)
assert_equal("http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd", html.internal_subset.system_id)
assert_equal(
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">", html.to_s[0,
97]
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">",
html.to_s[0, 97]
)
end

Expand Down Expand Up @@ -614,7 +616,7 @@ def test_find_classes
EOHTML
list = doc.css(".red")
assert_equal(2, list.length)
assert_equal(%w{RED RED}, list.map(&:text))
assert_equal(["RED", "RED"], list.map(&:text))
end

def test_parse_can_take_io
Expand Down Expand Up @@ -836,8 +838,10 @@ def initialize(*args)

it "passes arguments to #initialize" do
doc = klass.new("http://www.w3.org/TR/REC-html40/loose.dtd", "-//W3C//DTD HTML 4.0 Transitional//EN")
assert_equal(["http://www.w3.org/TR/REC-html40/loose.dtd", "-//W3C//DTD HTML 4.0 Transitional//EN"],
doc.initialized_with)
assert_equal(
["http://www.w3.org/TR/REC-html40/loose.dtd", "-//W3C//DTD HTML 4.0 Transitional//EN"],
doc.initialized_with
)
end
end

Expand Down

0 comments on commit c4a9de4

Please sign in to comment.