Sha256: 476348bd757f69aed4feec9db60f915bad40a05a746fb416e9858aeafc8266a1

Contents?: true

Size: 411 Bytes

Versions: 14

Compression:

Stored size: 411 Bytes

Contents

require "tempfile"

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

14 entries across 14 versions & 3 rubygems

Version Path
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/appraisal-2.5.0/spec/support/stream_helpers.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/appraisal-2.5.0/spec/support/stream_helpers.rb
appraisal-2.5.0 spec/support/stream_helpers.rb
appraisal-2.4.1 spec/support/stream_helpers.rb
appraisal-2.4.0 spec/support/stream_helpers.rb
appraisal-2.3.0 spec/support/stream_helpers.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/appraisal-2.2.0/spec/support/stream_helpers.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/appraisal-2.2.0/spec/support/stream_helpers.rb
appraisal-2.2.0 spec/support/stream_helpers.rb
appraisal-2.1.0 spec/support/stream_helpers.rb
appraisal-2.0.2 spec/support/stream_helpers.rb
appraisal-2.0.1 spec/support/stream_helpers.rb
appraisal-2.0.0 spec/support/stream_helpers.rb
appraisal-1.0.3 spec/support/stream_helpers.rb