-
-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Differ does not report differences in string arrays #518
Comments
FWIW, the ridiculous workaround I've come up with as a temporary hack to debug failing tests is this: context 'as string map values' do
it 'is equal' do
d1s = d1.map(&:inspect)
d2s = d2.map(&:inspect)
expect(d1s.map { |v| { v: v } }).to eq(d2s.map { |v| { v: v } })
end
end Which produces the at-least-somewhat-readable array diff:
|
Can you dig why it was done initially? I found "Extract diffing code from expectations to support" commit, and it leads to a different repo. |
@pirj See this commit in rspec-expectations (also linked above). Note that the code was in fail_with.rb at that time. |
Ah, sorry, I've missed this. The original reasoning of not showing such diffs: -that
+this doesn't really apply to string arrays. Would you like to submit a PR? |
@pirj Done. |
Subject of the issue
When comparing two arrays of objects, Differ provides a useful report on which expected objects are missing and which unexpected objects are present. When comparing two arrays of strings, however, the array diff is omitted and only the truncated
inspect
diff is present.Looking at the source code, it appears this was sort of intentional; but on the other hand it looks as though the original change back in 2010 was only intended to make sure the multiline differ wasn't applied to single-line strings. Ignoring all single-line string arrays just seems to have been a side effect.
Your environment
Steps to reproduce
Run the following (failing) spec:
Expected behavior
Failure messages for both tests should show the array diff.
Actual behavior
Only the failure message for
as objects
shows the array diff.The text was updated successfully, but these errors were encountered: