-
-
Notifications
You must be signed in to change notification settings - Fork 395
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
Compound expectations of OutputMatcher do not print a diff in their failure output, but Single expectations do #1406
Comments
I've done some debugging and have found that when the failure output lands in |
Same as rspec/rspec#89? |
@pirj i saw that issue but I don’t believe this is the same issue. The capturing of the output is ok, no problems there. It’s just on the diff part of the failure message where there’s an issue, so this is separate and different, and the fix commented in that issue doesn’t apply here. i.E. the assertions are fine; it’s the failure output that can be improved :) I’ll see if I can make a fix but I got so dizzy trawling through the code to find where actual can be set to a string instead, so I paused that and made this issue in case anyone had quick insider knowledge on where the fix needs to go. |
Fair enough. |
#1319 fixes this. But it's targeted to RSpec 4.
|
Ah wonderful! Thanks @pirj =) I've looked at that PR and it seems like it might be applicable to RSpec 3 too? Do you know if that's something you and the team would look at backporting? If not, is there a vague milestone or date for RSpec 4 to be released? Thanks v much =) |
Would really love this in 3.x if it's an easy rebase |
🥳 |
Subject of the issue
Using
output('something').to_stdout.and output('other thing').to_stderr
does not print a helpful diff when either of both of the assertions fail.Using
output('something').to_stdout
oroutput('other thing').to_stderr
individually always print a helpful diff when they fail.This means a helpful failure diff is lost if I want to assert on both stdout and stderr in the same assertion. I'm currently testing on large output that gets truncated, so the diff failure output is extremely helpful to me =)
A workaround I thought about is to have two separate assertions, but then that means the assertion with
.to_stdout
causes stderr to be printed to the terminal that runs the test, and vice versa for.to_stderr
allowing stdout to be printed to the terminal.But it was too much output and very messy to inspect the full output at the end of it. I'd rather have both stdout and stderr suppressed (and captured of course) so they can be diffed when an assertion fails =)
Your environment
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]
Steps to reproduce
Expected behavior
The failure output in the specific example above isn't particularly representative of how helpful the diff is, but when there are many, many lines of different content, it's very helpful =)
Actual behavior
The text was updated successfully, but these errors were encountered: