rspec-expectations icon indicating copy to clipboard operation
rspec-expectations copied to clipboard

Support compound stream matchers

Open nevinera opened this issue 1 year ago • 3 comments

Currently, compound stream matchers aren't properly supported, because when the CompoundMatcher nests them, the inner matcher doesn't expose the captured output to the outer matcher. This results in #1391.

While resolving the issue for the to_stderr_from_any_process though, I found an additional problem, which is that this matcher didn't properly restore the RSpec::Support::StdErrSplitter to its original state after capturing (it leaves it pointed at a now-dead Tempfile stream).

This PR will be in draft state until I work out a resolution for that.

Fixes #1391

nevinera avatar May 19 '24 04:05 nevinera

I think this is the solution: https://github.com/rspec/rspec-support/pull/598

nevinera avatar May 20 '24 02:05 nevinera

There does still seem to be some issue in JRuby - it looks like JRuby has a different implementation of Tempfile, and as a result, the existing stream-reopen behavior doesn't produce objects that can distinguished from the original as we're currently doing. I'll be back once I can get JRuby working locally, I've never done anything in there -.-

nevinera avatar May 21 '24 02:05 nevinera

I can reproduce those two failures on JRuby 9.4.7.0 + OpenJDK 22, which were a breeze to install with rvm/homebrew.

The only difference I could find is:

image

But to_io makes them return true in both cases for is_a?(File), even though both before and after to_io those are of a class Tempfile.

Is there anything else I can dig for you? What are your suspects?

pirj avatar Jun 24 '24 21:06 pirj

I'm closing this as part of the monorepo migration because its a draft, but if you wanted to reopen it @nevinera it should be easier to work with there.

JonRowe avatar Nov 30 '24 11:11 JonRowe