This repository was archived by the owner on Nov 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +18
-10
lines changed Expand file tree Collapse file tree 1 file changed +18
-10
lines changed Original file line number Diff line number Diff line change 101
101
102
102
# This spec replicates what matchers do when capturing stderr, e.g `to_stderr_from_any_process`
103
103
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
-
111
104
cloned = splitter . clone
112
- expect ( splitter . to_io ) . not_to be_a ( File )
105
+ expect ( splitter . to_io ) . to be_stderr
113
106
114
107
tempfile = Tempfile . new ( "foo" )
115
108
begin
116
109
splitter . reopen ( tempfile )
117
- expect ( splitter . to_io ) . to be_a ( File )
110
+ expect ( splitter . to_io ) . to_not be_stderr
118
111
ensure
119
112
splitter . reopen ( cloned )
120
113
tempfile . close
121
114
tempfile . unlink
122
115
end
123
116
# 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
125
133
end
126
134
end
You can’t perform that action at this time.
0 commit comments