This repository was archived by the owner on Nov 30, 2024. It is now read-only.
File tree 1 file changed +16
-8
lines changed
1 file changed +16
-8
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
- " ""
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"
109
106
end
110
107
111
108
cloned = splitter . clone
112
- expect ( splitter . to_io ) . not_to be_a ( File )
109
+ expect ( splitter . to_io ) . to be_stderr
113
110
114
111
tempfile = Tempfile . new ( "foo" )
115
112
begin
116
113
splitter . reopen ( tempfile )
117
- expect ( splitter . to_io ) . to be_a ( File )
114
+ expect ( splitter . to_io ) . to_not be_stderr
118
115
ensure
119
116
splitter . reopen ( cloned )
120
117
tempfile . close
121
118
tempfile . unlink
122
119
end
123
120
# 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
125
133
end
126
134
end
You can’t perform that action at this time.
0 commit comments