File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,14 +26,19 @@ def teardown
2626 end
2727 end
2828
29- if $stderr != $oldstderr && !$stderr. string . empty?
29+ #note this skips the output check in environments like rubymine that hijack the output. Alternative is a method missing error on string
30+
31+ if $stderr != $oldstderr && $stderr. respond_to? ( :string ) && !$stderr. string . empty?
3032 # we ignore 2.X because of the number of `instance variable @xyz not initialized` warnings
3133 if !RUBY_VERSION . start_with? ( '2.' )
3234 raise "Unexpected stderr. Handle stderr with assert_stderr\n \n #{ $stderr. string } "
3335 end
3436 end
3537
36- $stderr = $oldstderr
38+ # Only restore stderr if we have a valid oldstderr
39+ if $oldstderr
40+ $stderr = $oldstderr
41+ end
3742
3843 Timecop . return
3944 end
@@ -174,6 +179,7 @@ def assert_logged(expected)
174179 end
175180
176181 def assert_stderr ( expected )
182+ skip "Cannot verify stderr in current environment" unless $stderr. respond_to? ( :string )
177183 $stderr. string . split ( "\n " ) . uniq . each do |line |
178184 matched = false
179185
You can’t perform that action at this time.
0 commit comments