approvals / approvals/ApprovalTests.Ruby
Differences in jruby and mri json output
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 231
- Forks
- 45
- PR merge metrics
- No merged PRs in 30d
Description
I often have the problem that there are minor differences between the output of an approval test in jruby and mri. We run our tests in both rubies so the approval test always fails for such cases in one of the rubies.
An example of this is that the following generates different approvals in jruby and mri:
verify(format: :json) { { weight: {} } }
In jruby:
weight: {
}
in mri:
weight: {
}
Is there any way to avoid this?
The problem seems to be jsons pretty_generate: https://github.com/kytrinyx/approvals/blob/master/lib/approvals/writers/json_writer.rb#L11
jruby:
JSON.pretty_generate({ weight: {} })
=> "{\n \"weight\": {\n\n }\n}"`
mri:
JSON.pretty_generate({ weight: {} })
=> "{\n \"weight\": {\n }\n}"
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lib/approvals/writers/json_writer.rb at the JSON.pretty_generate call, then reproduce the shown output on MRI and JRuby. Done means approval output for the same JSON input is consistent across both Ruby runtimes; the issue does not name a test file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100