Show a diff for comparisons of arrays of one-line strings #597
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A long time ago, a fellow notice a regression in the behavior of diffing. Roughly speaking,
expect(["foo"]).to eq(["foo", "baz"])
doesn't print a "Diff" section of output. Butexpect(["foo"]).to eq(["foo", "baz\n"])
does. And that seems like an odd distinction to make! To the code mines!I had to trace this across the move from rspec-expectations into rspec-support, but it was originally introduced here, which was motivated by this issue. That seems like a reasonable goal, and we do actually have some tests enforcing it already (though they're a little entangled with the encoding specs - I can add another test specific to this purpose if you like). The effect it had on diffing arrays of strings seems incidental though, a result of the way we flatten the arrays to test them, rather than checking them individually.
So! Break that check out ahead, and make it a bit clearer - add
pointless_diff?
, which tests that both arguments are Strings, and that neither string is multiline; for that case, skip adding the diff like before, but drop the 'multiline' test that was skipping.