Sha256: 75d4fc9d1532dfbfc4c9db2bf98bb12b35350e1e0c32fb96542833f27ac695c3

Contents?: true

Size: 318 Bytes

Versions: 16

Compression:

Stored size: 318 Bytes

Contents

require 'stringio'

#
# Capture STDOUT and STDERR
#
def capture(*streams)
  streams.map! { |stream| stream.to_s }
  begin
    result = StringIO.new
    streams.each { |stream| eval "$#{stream} = result" }
    yield
  ensure
    streams.each { |stream| eval("$#{stream} = #{stream.upcase}") }
  end
  result.string
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
quorum-0.8.2 spec/support/streams.rb
quorum-0.8.1 spec/support/streams.rb
quorum-0.8.0 spec/support/streams.rb
quorum-0.7.1 spec/support/streams.rb
quorum-0.7.0 spec/support/streams.rb
quorum-0.6.0 spec/support/streams.rb
quorum-0.5.2 spec/support/streams.rb
quorum-0.5.1 spec/support/streams.rb
quorum-0.5.0 spec/support/streams.rb
quorum-0.4.0 spec/support/streams.rb
quorum-0.3.3 spec/support/streams.rb
quorum-0.3.2 spec/support/streams.rb
quorum-0.3.1 spec/support/streams.rb
quorum-0.3.0 spec/support/streams.rb
quorum-0.2.1 spec/support/streams.rb
quorum-0.2.0 spec/support/streams.rb