Sha256: 4c57852a7cb9efc37f5cafbac1871d5473d1ce57d02f0170716e810f5793b8b8

Contents?: true

Size: 504 Bytes

Versions: 5

Compression:

Stored size: 504 Bytes

Contents

module Vault::Test::EnvironmentHelpers
  # Override an ENV variable for the current test.  The original value will be
  # restored automatically when the test finishes.
  def set_env(key, value)
    overrides[key] = ENV[key] unless overrides.has_key?(key)
    ENV[key] = value
  end

  def teardown
    overrides.each { |key, value| ENV[key] = value }
    super
  end

  private

  # The overridden environment variables to restore when the test finishes.
  def overrides
    @overrides ||= {}
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vault-test-tools-0.3.4 lib/vault-test-tools/environment_helpers.rb
vault-test-tools-0.3.3 lib/vault-test-tools/environment_helpers.rb
vault-test-tools-0.3.2 lib/vault-test-tools/environment_helpers.rb
vault-test-tools-0.3.1 lib/vault-test-tools/environment_helpers.rb
vault-test-tools-0.3.0 lib/vault-test-tools/environment_helpers.rb