diff --git a/test/support/common_helpers.rb b/test/support/common_helpers.rb index f2607e6..261ed58 100644 --- a/test/support/common_helpers.rb +++ b/test/support/common_helpers.rb @@ -26,14 +26,19 @@ def teardown end end - if $stderr != $oldstderr && !$stderr.string.empty? + #note this skips the output check in environments like rubymine that hijack the output. Alternative is a method missing error on string + + if $stderr != $oldstderr && $stderr.respond_to?(:string) && !$stderr.string.empty? # we ignore 2.X because of the number of `instance variable @xyz not initialized` warnings if !RUBY_VERSION.start_with?('2.') raise "Unexpected stderr. Handle stderr with assert_stderr\n\n#{$stderr.string}" end end - $stderr = $oldstderr + # Only restore stderr if we have a valid oldstderr + if $oldstderr + $stderr = $oldstderr + end Timecop.return end @@ -174,6 +179,7 @@ def assert_logged(expected) end def assert_stderr(expected) + skip "Cannot verify stderr in current environment" unless $stderr.respond_to?(:string) $stderr.string.split("\n").uniq.each do |line| matched = false