Module: RSpecFixtures::CaptureStderr

Defined in:
lib/rspec_fixtures/stream_capturer.rb

Class Method Summary collapse

Class Method Details

.capture(block) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rspec_fixtures/stream_capturer.rb', line 22

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

  original_stream = $stderr
  $stderr = captured_stream

  block.call

  captured_stream.string
ensure
  $stderr = original_stream
end