Module: Docspec::OutputCapturer

Included in:
Example
Defined in:
lib/docspec/output_capturer.rb

Instance Method Summary collapse

Instance Method Details

#capture_outputObject



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/docspec/output_capturer.rb', line 5

def capture_output
  original_stdout = $stdout
  $stdout = StringIO.new
  begin
    yield
    $stdout.string
  rescue => e
    "#{$stdout.string}#{e.inspect}"
  ensure
    $stdout = original_stdout
  end
end