Skip to content

Commit

Permalink
Merge pull request #46 from hotgazpacho/html-writer
Browse files Browse the repository at this point in the history
  • Loading branch information
kytrinyx committed Apr 5, 2014
2 parents f97c7a7 + 05dc7f6 commit 89a4552
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/approvals/writers/html_writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def extension
end

def format(data)
Nokogiri::XML(data.to_s.strip,&:noblanks).to_xhtml(:indent => 2, :encoding => 'UTF-8')
Nokogiri::HTML(data.to_s.strip,&:noblanks).to_xhtml(:indent => 2, :encoding => 'UTF-8')
end

end
Expand Down
11 changes: 11 additions & 0 deletions spec/approvals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ def hello.inspect
Approvals.verify html, :format => :html, :namer => namer
end

it "verifies a malformed html fragment" do
html = <<-HTML
<!DOCTYPE html>
<html>
<title>Hoi</title>
<script async defer src="http://foo.com/bar.js"></script>
<h1>yo</h1>
HTML
Approvals.verify html, :format => :html, :namer => namer
end

it "verifies xml" do
xml = "<xml char=\"kiddo\"><node><content name='beatrice' /></node><node aliases='5'><content /></node></xml>"
Approvals.verify xml, :format => :xml, :namer => namer
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Hoi</title>
<script async="" defer="defer" src="http://foo.com/bar.js"></script>
</head>
<body>
<h1>yo</h1>
</body>
</html>

0 comments on commit 89a4552

Please sign in to comment.