Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions test/support/common_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down