blob: f54ec42f69fe78cba1d6faac8f41b8acb215865b (
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
|
require 'stringio'
# Mix-in for capturing standard output.
module CaptureStdout
def capture_stdout
s = StringIO.new
oldstdout = $stdout
$stdout = s
yield
s.string
ensure
$stdout = oldstdout
end
def capture_stderr
s = StringIO.new
oldstderr = $stderr
$stderr = s
yield
s.string
ensure
$stderr = oldstderr
end
end
|