Sha256: 84b0e7fcd31524984601a0c5213d184e0dba42f663c21b44337859dc421f047d

Contents?: true

Size: 391 Bytes

Versions: 12

Compression:

Stored size: 391 Bytes

Contents

module StreamHelpers
  def capture(stream)
    stream = stream.to_s
    captured_stream = Tempfile.new(stream)
    stream_io = eval("$#{stream}")
    origin_stream = stream_io.dup
    stream_io.reopen(captured_stream)

    yield

    stream_io.rewind
    return captured_stream.read
  ensure
    captured_stream.close
    captured_stream.unlink
    stream_io.reopen(origin_stream)
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rolify-6.0.1 spec/support/stream_helpers.rb
rolify-6.0.0 spec/support/stream_helpers.rb
rolify-5.3.0 spec/support/stream_helpers.rb
rolify-5.2.0 spec/support/stream_helpers.rb
rolify-5.1.0 spec/support/stream_helpers.rb
rolify-5.0.0 spec/support/stream_helpers.rb
rolify-4.1.1 spec/support/stream_helpers.rb
rolify-4.1.0 spec/support/stream_helpers.rb
rolify-4.0.0 spec/support/stream_helpers.rb
rolify-3.5.2 spec/support/stream_helpers.rb
rolify-3.5.1 spec/support/stream_helpers.rb
rolify-3.5.0 spec/support/stream_helpers.rb