Sha256: c1ecd3081e1fbb33e3e479c4c9bf21bc208b83ce512b88d3b3373e1b58b08033

Contents?: true

Size: 717 Bytes

Versions: 4

Compression:

Stored size: 717 Bytes

Contents

class Environment
  attr_reader :sandbox
  attr_accessor :env

  def initialize
    ENV['TMPDIR'] = '/tmp' # Work-around for bundler bug with '++' in path name.
    @sandbox = Sandbox.new
    @env = ENV.to_hash
  end

  def cleanup
    @sandbox.close
  end

  BUNDLER_ENVIRONMENT_VARIABLES = [ 'BUNDLE_BIN_PATH', 'BUNDLE_GEMFILE', 'RUBYOPT', 'GEM_HOME', 'GEM_PATH' ]
  def unbundlerize!
    BUNDLER_ENVIRONMENT_VARIABLES.each {|v| env.delete(v)}
  end

  def with_env
    old_env = ENV.to_hash
    ENV.replace(@env)
    begin
      yield
    ensure
      ENV.replace(old_env)
    end
  end
  private :with_env

  def enter
    Dir.chdir(@sandbox.path) do
      with_env do
        yield
      end
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
iCuke-0.7.0 features/support/environment.rb
iCuke-0.6.6 features/support/environment.rb
iCuke-0.6.5 features/support/environment.rb
iCuke-0.6.4 features/support/environment.rb