Skip to content

[rspec-expectations] Fix output.to_stdout_from_any_process when $stdout has been reassigned #151

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

JonRowe
Copy link
Member

@JonRowe JonRowe commented Nov 30, 2024

This is rspec/rspec-expectations#1486

(An alternate fix for rspec/rspec-core#3113)

When running under rspec bisect runner, $stdout & $stderr are reassigned to a StringIO, which would cause "can't convert Tempfile into StringIO" when trying to reopen the stream in CaptureStreamToTempfile

Since CaptureStreamToTempfile reopens the stream rather than reassigning it, I think it makes sense to use STDOUT rather than whatever the current value of $stdout is.

(Please feel free to sanity-check that assumption. I've gone round in circles a few too many times on this)

When running under rspec bisect runner, $stdout & $stderr are reassigned
to a StringIO, which would introduce spec errors.

("can't convert Tempfile into StringIO", when trying to reopen the
stream in CaptureStreamToTempfile)

Since CaptureStreamToTempfile reopens the stream rather than reassigning
it, I _think_ it makes sense to use STDOUT rather than whatever the
current value of $stdout is.
Otherwise it doesn't work when $stderr has previously been reassigned,
like in the rspec-core test suite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants