Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit cedf81e

Browse files
committed
WIP fix for Jruby spec
1 parent 08d2bcd commit cedf81e

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

spec/rspec/support/spec/stderr_splitter_spec.rb

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,26 +101,34 @@
101101

102102
# This spec replicates what matchers do when capturing stderr, e.g `to_stderr_from_any_process`
103103
it 'is able to restore the stream from a cloned StdErrSplitter' do
104-
if RSpec::Support::Ruby.jruby?
105-
skip """
106-
This spec is currently unsupported on JRuby on CI due to tempfiles not being
107-
a file, this situtation was discussed here https://github.com/rspec/rspec-support/pull/598#issuecomment-2200779633
108-
"""
109-
end
110-
111104
cloned = splitter.clone
112-
expect(splitter.to_io).not_to be_a(File)
105+
expect(splitter.to_io).to be_stderr
113106

114107
tempfile = Tempfile.new("foo")
115108
begin
116109
splitter.reopen(tempfile)
117-
expect(splitter.to_io).to be_a(File)
110+
expect(splitter.to_io).to_not be_stderr
118111
ensure
119112
splitter.reopen(cloned)
120113
tempfile.close
121114
tempfile.unlink
122115
end
123116
# This is the important part of the test that would fail without proper cloning hygeine
124-
expect(splitter.to_io).not_to be_a(File)
117+
expect(splitter.to_io).to be_stderr
118+
end
119+
120+
# Detecting STDERR in a way that doesn't use a reference
121+
if STDERR.respond_to?(:path)
122+
def be_stderr
123+
have_attributes({:path => '<STDERR>'})
124+
end
125+
elsif STDERR.inspect =~ /STDERR/
126+
def be_stderr
127+
have_attributes({:inspect => "#<IO:<STDERR>>"})
128+
end
129+
else
130+
def be_stderr
131+
raise skip "JRuby < 9.0.0.0 doesn't have a predictable identifier for stdout"
132+
end
125133
end
126134
end

0 commit comments

Comments
 (0)