aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/helper
diff options
context:
space:
mode:
authorJosh Hagins2016-10-19 12:32:48 -0400
committerJosh Hagins2016-10-19 12:35:46 -0400
commitfba00f2bbfd970ece1d2503a333a9a2730ae5b63 (patch)
tree0d2de8acd1e9ff8539911d963bed17f1033d33ed /Library/Homebrew/test/helper
parentb9fe36abdc5f1898be3f7884086bee5674ee0528 (diff)
downloadbrew-fba00f2bbfd970ece1d2503a333a9a2730ae5b63.tar.bz2
testing_env: extract with_environment to helper module
Diffstat (limited to 'Library/Homebrew/test/helper')
-rw-r--r--Library/Homebrew/test/helper/env.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/Library/Homebrew/test/helper/env.rb b/Library/Homebrew/test/helper/env.rb
new file mode 100644
index 000000000..904a1d4c7
--- /dev/null
+++ b/Library/Homebrew/test/helper/env.rb
@@ -0,0 +1,15 @@
+module Test
+ module Helper
+ module Env
+ def with_environment(partial_env)
+ old = ENV.to_hash
+ ENV.update partial_env
+ begin
+ yield
+ ensure
+ ENV.replace old
+ end
+ end
+ end
+ end
+end