summaryrefslogtreecommitdiffstats
path: root/test/ext/capture_output.rb
blob: 930f4080ed4a874123b019e0904e34784729324b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module CaptureOutput
  def before_setup
    super
    @stderr = StringIO.new
    @stdout = StringIO.new
    return if ENV['VERBOSE']
    $stderr = @stderr
    $stdout = @stdout
  end
  def after_teardown
    super
    return if ENV['VERBOSE']
    $stderr = STDERR
    $stdout = STDOUT
  end
  def error_output
    @stderr.string
  end
  def standard_output
    @stdout.string
  end
end
class MiniTest::Test
  include CaptureOutput
end