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

Commit 582cce3

Browse files
committed
WIP fix for Jruby spec
1 parent 8d28308 commit 582cce3

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

spec/rspec/support/spec/stderr_splitter_spec.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,26 +101,28 @@
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+
def be_stderr
126+
have_attributes({:inspect => "#<IO:<STDERR>>"})
125127
end
126128
end

0 commit comments

Comments
 (0)