Sha256: d8b4017f03e6de288bbc35955180a2a805d78b003d58b88b12beda917d4bbd7b

Contents?: true

Size: 350 Bytes

Versions: 56

Compression:

Stored size: 350 Bytes

Contents

module StdoutCapture
  # Captures stdout within the block
  # Usage:
  #
  #   out = capture_stdout do
  #     puts "this will not be shown"
  #   end
  #   out.should == "this will not be shown"
  def capture_stdout(&block)
    out = StringIO.new
    $stdout = out
    yield
    out.rewind
    return out.read
  ensure
    $stdout = STDOUT
  end
end

Version data entries

56 entries across 56 versions & 2 rubygems

Version Path
bosh-bootstrap-0.18.1 spec/support/capture_stdout.rb
bosh-bootstrap-0.18.0 spec/support/capture_stdout.rb
bosh-bootstrap-0.17.1 spec/support/capture_stdout.rb
bosh-bootstrap-0.17.0 spec/support/capture_stdout.rb
bosh-bootstrap-0.16.2 spec/support/capture_stdout.rb
bosh-bootstrap-0.16.1 spec/support/capture_stdout.rb
cyoi-0.11.3 spec/support/stdout_capture.rb
bosh-bootstrap-0.16.0 spec/support/capture_stdout.rb
bosh-bootstrap-0.15.0 spec/support/capture_stdout.rb
bosh-bootstrap-0.14.5 spec/support/capture_stdout.rb
cyoi-0.11.2 spec/support/stdout_capture.rb
bosh-bootstrap-0.14.4 spec/support/capture_stdout.rb
bosh-bootstrap-0.14.3 spec/support/capture_stdout.rb
bosh-bootstrap-0.14.2 spec/support/capture_stdout.rb
bosh-bootstrap-0.14.1 spec/support/capture_stdout.rb
cyoi-0.11.1 spec/support/stdout_capture.rb
bosh-bootstrap-0.14.0 spec/support/capture_stdout.rb
cyoi-0.11.0 spec/support/stdout_capture.rb
bosh-bootstrap-0.13.2 spec/support/capture_stdout.rb
cyoi-0.10.1 spec/support/stdout_capture.rb