aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorMisty De Meo2017-07-18 12:53:54 -0700
committerGitHub2017-07-18 12:53:54 -0700
commitf8300b2cb720ca0c25c6b8fbee2df84b5a210b2a (patch)
tree9b439c569172d33dfd7f5dd725b9497a3ed11c26 /Library/Homebrew/test
parentc6f8887deb892f9ad34cb70a97aa195d40b040e0 (diff)
parent32b7e32856e61f256f2703faa17cdbcee26e17b7 (diff)
downloadbrew-f8300b2cb720ca0c25c6b8fbee2df84b5a210b2a.tar.bz2
Merge pull request #2883 from mistydemeo/allow_passing_hash_to_system
Allow passing hash to system
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/utils_spec.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/Library/Homebrew/test/utils_spec.rb b/Library/Homebrew/test/utils_spec.rb
index f3bf98486..37bd83c4f 100644
--- a/Library/Homebrew/test/utils_spec.rb
+++ b/Library/Homebrew/test/utils_spec.rb
@@ -270,4 +270,30 @@ describe "globally-scoped helper methods" do
}.to raise_error(MethodDeprecatedError, %r{method.*replacement.*homebrew/homebrew-core.*homebrew/core}m)
end
end
+
+ describe "#with_env" do
+ it "sets environment variables within the block" do
+ expect(ENV["PATH"]).not_to eq("/bin")
+ with_env "PATH" => "/bin" do
+ expect(ENV["PATH"]).to eq("/bin")
+ end
+ end
+
+ it "restores ENV after the block" do
+ with_env "PATH" => "/bin" do
+ expect(ENV["PATH"]).to eq("/bin")
+ end
+ expect(ENV["PATH"]).not_to eq("/bin")
+ end
+
+ it "restores ENV if an exception is raised" do
+ expect {
+ with_env "PATH" => "/bin" do
+ raise StandardError, "boom"
+ end
+ }.to raise_error(StandardError)
+
+ expect(ENV["PATH"]).not_to eq("/bin")
+ end
+ end
end