Module: RSpecFixtures::CaptureStdout

Defined in:
lib/rspec_fixtures/stream_capturer.rb

Overview

Class Method Summary collapse

Class Method Details

.capture(block) ⇒ Object



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

def self.capture(block)
  captured_stream = StringIO.new

  original_stream = $stdout
  $stdout = captured_stream

  block.call

  captured_stream.string
ensure
  $stdout = original_stream
end