Files
codeocean/spec/support/silencer.rb
2021-05-14 22:03:06 +02:00

14 lines
225 B
Ruby

# frozen_string_literal: true
module Silencer
def silenced
@stdout = $stdout
$stdout = Tempfile.new('stdout')
yield if block_given?
ensure
$stdout.close
$stdout.unlink
$stdout = @stdout
end
end