Sha256: 2e18076fc4584724787a8b1a3c16478a3342aaddf20840a3d8c3d013d5af51f6

Contents?: true

Size: 411 Bytes

Versions: 53

Compression:

Stored size: 411 Bytes

Contents

module CaptureOutputHelper
  def capture_output(&block)
    old_stdout = $stdout
    old_stderr = $stderr

    stream_out = StringIO.new
    stream_err = StringIO.new

    begin
      $stdout = stream_out
      $stderr = stream_err
      yield
    ensure
      $stdout = old_stdout
      $stderr = old_stderr
    end
    stream_out.rewind
    stream_err.rewind

    [stream_out.read, stream_err.read]
  end
end

Version data entries

53 entries across 53 versions & 4 rubygems

Version Path
rake-compiler-1.2.2 spec/support/capture_output_helper.rb
rake-compiler-1.2.1 spec/support/capture_output_helper.rb
rake-compiler-1.2.0 spec/support/capture_output_helper.rb
rake-compiler-1.1.9 spec/support/capture_output_helper.rb
rake-compiler-1.1.8 spec/support/capture_output_helper.rb
rake-compiler-1.1.7 spec/support/capture_output_helper.rb
rake-compiler-1.1.6 spec/support/capture_output_helper.rb
rake-compiler-1.1.5 spec/support/capture_output_helper.rb
rake-compiler-1.1.4 spec/support/capture_output_helper.rb
rake-compiler-1.1.3 spec/support/capture_output_helper.rb
rake-compiler-1.1.2 spec/support/capture_output_helper.rb
rake-compiler-1.1.1 spec/support/capture_output_helper.rb
rake-compiler-1.1.0 spec/support/capture_output_helper.rb
rake-compiler-1.0.9 spec/support/capture_output_helper.rb
rake-compiler-1.0.8 spec/support/capture_output_helper.rb
rake-compiler-1.0.7 spec/support/capture_output_helper.rb
rake-compiler-1.0.6 spec/support/capture_output_helper.rb
rake-compiler-1.0.5 spec/support/capture_output_helper.rb
rake-compiler-1.0.4 spec/support/capture_output_helper.rb
rake-compiler-1.0.3 spec/support/capture_output_helper.rb