aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask
diff options
context:
space:
mode:
authorAlyssa Ross2017-01-23 17:54:31 +0000
committerGitHub2017-01-23 17:54:31 +0000
commit2c1fbe16931bd366d33d4419c59fcc8ada9cfe7d (patch)
tree7dec252366b87b02b7ad9171e3b618f03ecc2ee7 /Library/Homebrew/cask
parentd6932548f89c48e6c33df4c24685ae58904e9b7a (diff)
parent62a0c3a6f5cd6577cf9e628524b88b91b9419df7 (diff)
downloadbrew-2c1fbe16931bd366d33d4419c59fcc8ada9cfe7d.tar.bz2
Merge pull request #1890 from alyssais/global_teardown_env
tests: automatically restore ENV in teardown
Diffstat (limited to 'Library/Homebrew/cask')
-rw-r--r--Library/Homebrew/cask/spec/cask/cli_spec.rb16
-rw-r--r--Library/Homebrew/cask/spec/spec_helper.rb2
-rw-r--r--Library/Homebrew/cask/test/cask/dsl_test.rb6
-rw-r--r--Library/Homebrew/cask/test/test_helper.rb2
4 files changed, 13 insertions, 13 deletions
diff --git a/Library/Homebrew/cask/spec/cask/cli_spec.rb b/Library/Homebrew/cask/spec/cask/cli_spec.rb
index 9964275f1..6b2313a41 100644
--- a/Library/Homebrew/cask/spec/cask/cli_spec.rb
+++ b/Library/Homebrew/cask/spec/cask/cli_spec.rb
@@ -39,17 +39,17 @@ describe Hbc::CLI do
end
it "respects the env variable when choosing what appdir to create" do
- with_environment "HOMEBREW_CASK_OPTS" => "--appdir=/custom/appdir" do
- expect(Hbc).to receive(:appdir=).with(Pathname("/custom/appdir"))
- described_class.process("noop")
- end
+ allow(ENV).to receive(:[])
+ allow(ENV).to receive(:[]).with("HOMEBREW_CASK_OPTS").and_return("--appdir=/custom/appdir")
+ expect(Hbc).to receive(:appdir=).with(Pathname.new("/custom/appdir"))
+ described_class.process("noop")
end
it "respects the env variable when choosing a non-default Caskroom location" do
- with_environment "HOMEBREW_CASK_OPTS" => "--caskroom=/custom/caskdir" do
- expect(Hbc).to receive(:caskroom=).with(Pathname("/custom/caskdir"))
- described_class.process("noop")
- end
+ allow(ENV).to receive(:[])
+ allow(ENV).to receive(:[]).with("HOMEBREW_CASK_OPTS").and_return("--caskroom=/custom/caskdir")
+ expect(Hbc).to receive(:caskroom=).with(Pathname.new("/custom/caskdir"))
+ described_class.process("noop")
end
it "exits with a status of 1 when something goes wrong" do
diff --git a/Library/Homebrew/cask/spec/spec_helper.rb b/Library/Homebrew/cask/spec/spec_helper.rb
index 458fe00f4..162cb3b8f 100644
--- a/Library/Homebrew/cask/spec/spec_helper.rb
+++ b/Library/Homebrew/cask/spec/spec_helper.rb
@@ -15,7 +15,6 @@ require "global"
# add Homebrew-Cask to load path
$LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.join("cask", "lib").to_s)
-require "test/support/helper/env"
require "test/support/helper/shutup"
Pathname.glob(HOMEBREW_LIBRARY_PATH.join("cask", "spec", "support", "*.rb")).each(&method(:require))
@@ -38,6 +37,5 @@ end
RSpec.configure do |config|
config.order = :random
- config.include(Test::Helper::Env)
config.include(Test::Helper::Shutup)
end
diff --git a/Library/Homebrew/cask/test/cask/dsl_test.rb b/Library/Homebrew/cask/test/cask/dsl_test.rb
index 96d24a1a1..0ea928f40 100644
--- a/Library/Homebrew/cask/test/cask/dsl_test.rb
+++ b/Library/Homebrew/cask/test/cask/dsl_test.rb
@@ -69,7 +69,11 @@ describe Hbc::DSL do
end
it "may use deprecated DSL version hash syntax" do
- with_environment "HOMEBREW_DEVELOPER" => nil do
+ stub = proc do |arg|
+ arg == "HOMEBREW_DEVELOPER" ? nil : ENV[arg]
+ end
+
+ ENV.stub :[], stub do
shutup do
test_cask = Hbc.load("with-dsl-version")
test_cask.token.must_equal "with-dsl-version"
diff --git a/Library/Homebrew/cask/test/test_helper.rb b/Library/Homebrew/cask/test/test_helper.rb
index 275ede304..7315839f5 100644
--- a/Library/Homebrew/cask/test/test_helper.rb
+++ b/Library/Homebrew/cask/test/test_helper.rb
@@ -13,9 +13,7 @@ require "global"
# add Homebrew-Cask to load path
$LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.join("cask", "lib").to_s)
-require "test/support/helper/env"
require "test/support/helper/shutup"
-include Test::Helper::Env
include Test::Helper::Shutup
def sudo(*args)