aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/testing_env.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/test/testing_env.rb')
-rw-r--r--Library/Homebrew/test/testing_env.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/Library/Homebrew/test/testing_env.rb b/Library/Homebrew/test/testing_env.rb
index 6be622cc5..214aa9789 100644
--- a/Library/Homebrew/test/testing_env.rb
+++ b/Library/Homebrew/test/testing_env.rb
@@ -120,5 +120,15 @@ module Homebrew
def bundle_path(name)
Pathname.new("#{TEST_DIRECTORY}/mach/#{name}.bundle")
end
+
+ def with_environment(partial_env)
+ old = ENV.to_hash
+ ENV.update partial_env
+ begin
+ yield
+ ensure
+ ENV.replace old
+ end
+ end
end
end