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

Commit 414142d

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

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

spec/rspec/support/spec/stderr_splitter_spec.rb

+16-8
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-
"""
104+
if RSpec::Support::Ruby.jruby? && !RSpec::Support::Ruby.jruby_9000?
105+
skip "JRuby < 9.0.0.0 doesn't have a predictable identifier for stdout"
109106
end
110107

111108
cloned = splitter.clone
112-
expect(splitter.to_io).not_to be_a(File)
109+
expect(splitter.to_io).to be_stderr
113110

114111
tempfile = Tempfile.new("foo")
115112
begin
116113
splitter.reopen(tempfile)
117-
expect(splitter.to_io).to be_a(File)
114+
expect(splitter.to_io).to_not be_stderr
118115
ensure
119116
splitter.reopen(cloned)
120117
tempfile.close
121118
tempfile.unlink
122119
end
123120
# 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)
121+
expect(splitter.to_io).to be_stderr
122+
end
123+
124+
# Detecting STDERR in a way that doesn't use a reference
125+
if STDERR.respond_to?(:path)
126+
def be_stderr
127+
have_attributes({:path => '<STDERR>'})
128+
end
129+
else
130+
def be_stderr
131+
have_attributes({:inspect => "#<IO:<STDERR>>"})
132+
end
125133
end
126134
end

0 commit comments

Comments
 (0)