Sha256: 955147b83fe61d2d90db6dd471f6a6ae87c687f2c7350c3e1f3e4450d2c231cf

Contents?: true

Size: 313 Bytes

Versions: 10

Compression:

Stored size: 313 Bytes

Contents

def preserving_env
  old_env = ENV.to_hash
  begin
    yield
  ensure
    ENV.clear
    ENV.update(old_env)
  end
end

def capture_stdout
  old_stdout = $stdout.dup
  rd, wr = IO.method(:pipe).arity.zero? ? IO.pipe : IO.pipe("BINARY")
  $stdout = wr
  yield
  wr.close
  rd.read
ensure
  $stdout = old_stdout
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
cumuli-0.5.0 spec/support/functional_helpers.rb
cumuli-0.4.1 spec/support/functional_helpers.rb
cumuli-0.4.0 spec/support/functional_helpers.rb
cumuli-0.3.4 spec/support/functional_helpers.rb
cumuli-0.3.2 spec/support/functional_helpers.rb
cumuli-0.3.1 spec/support/functional_helpers.rb
cumuli-0.3.0 spec/support/functional_helpers.rb
cumuli-0.2.1 spec/support/functional_helpers.rb
cumuli-0.2.0 spec/support/functional_helpers.rb
cumuli-0.1.0 spec/support/functional_helpers.rb