approvals / approvals/ApprovalTests.Ruby

Differences in JRuby and MRI HTML output

Open
#88 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
231
Forks
45
PR merge metrics
No merged PRs in 30d

Description

Similar to issue #84 there are also differences in the HTML output between JRuby and MRI.

Example:

describe "a html response" do
  let(:test_html) do
<<-TEST
<!doctype html>
<head>
<title>Test Title</title>
<meta charset="utf-8"/>
</head>
<body>
<h1>Test Page</h1>
</body>
</html>
TEST
end

  it "a test" do
    verify do
      test_html
    end
  end
end

MRI Output
MRI: 2.5.3
Approvals: 0.0.24
Nokogiri: 1.10.1

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Test Title</title>
    <meta charset="utf-8" />
  </head>
  <body>
<h1>Test Page</h1>
</body>
</html>

JRuby Output
JRuby: 9.2.5.0
Approvals: 0.0.24
Nokogiri: 1.10.1-java

<!DOCTYPE html >
<html>
  <head>
    <title>Test Title</title>
    <meta charset="utf-8" />

  </head>
  <body>
    <h1>Test Page</h1>
  </body>
</html>

Workaround
A workaround is to use the format: :txt options, which produces the same (unchanged) output for both Ruby versions.

<!doctype html>
<head>
<title>Test Title</title>
<meta charset="utf-8"/>
</head>
<body>
<h1>Test Page</h1>
</body>
</html>

As far as I can tell, the issue is related to this line of code (https://github.com/kytrinyx/approvals/blob/master/lib/approvals/writers/html_writer.rb#L10), where Nokogiri produces a different output for each of the two Ruby versions.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with lib/approvals/writers/html_writer.rb at the Nokogiri-related line and reproduce the supplied HTML example under MRI and JRuby. Compare the generated output and determine how the writer should handle the runtime difference; done means equivalent HTML output is produced without requiring the format: :txt workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.