aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJosh Hagins2016-10-19 12:34:03 -0400
committerJosh Hagins2016-10-19 12:35:47 -0400
commite8b6aa4ed16b662cf7a3847e6f7995ca8c8e0194 (patch)
treee4062a0c7bbbd0572759f028715d3784f3db2b44 /Library
parentfba00f2bbfd970ece1d2503a333a9a2730ae5b63 (diff)
downloadbrew-e8b6aa4ed16b662cf7a3847e6f7995ca8c8e0194.tar.bz2
cask/spec: replace with_env_var with with_environment
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cask/spec/cask/cli_spec.rb4
-rw-r--r--Library/Homebrew/cask/spec/spec_helper.rb2
-rw-r--r--Library/Homebrew/cask/spec/support/env_helper.rb16
3 files changed, 4 insertions, 18 deletions
diff --git a/Library/Homebrew/cask/spec/cask/cli_spec.rb b/Library/Homebrew/cask/spec/cask/cli_spec.rb
index cb21dbd25..1bdc57b6e 100644
--- a/Library/Homebrew/cask/spec/cask/cli_spec.rb
+++ b/Library/Homebrew/cask/spec/cask/cli_spec.rb
@@ -41,14 +41,14 @@ describe Hbc::CLI do
end
it "respects the env variable when choosing what appdir to create" do
- EnvHelper.with_env_var("HOMEBREW_CASK_OPTS", "--appdir=/custom/appdir") do
+ with_environment "HOMEBREW_CASK_OPTS" => "--appdir=/custom/appdir" do
expect(Hbc).to receive(:appdir=).with(Pathname("/custom/appdir"))
described_class.process("noop")
end
end
it "respects the env variable when choosing a non-default Caskroom location" do
- EnvHelper.with_env_var "HOMEBREW_CASK_OPTS", "--caskroom=/custom/caskdir" do
+ with_environment "HOMEBREW_CASK_OPTS" => "--caskroom=/custom/caskdir" do
expect(Hbc).to receive(:caskroom=).with(Pathname("/custom/caskdir"))
described_class.process("noop")
end
diff --git a/Library/Homebrew/cask/spec/spec_helper.rb b/Library/Homebrew/cask/spec/spec_helper.rb
index 7dadc6b5c..ebd60124c 100644
--- a/Library/Homebrew/cask/spec/spec_helper.rb
+++ b/Library/Homebrew/cask/spec/spec_helper.rb
@@ -16,6 +16,7 @@ require "global"
# add Homebrew-Cask to load path
$LOAD_PATH.push(project_root.join("lib").to_s)
+require "test/helper/env"
require "test/helper/shutup"
Dir["#{project_root}/spec/support/*.rb"].each(&method(:require))
@@ -61,5 +62,6 @@ Hbc.caskroom = Hbc.homebrew_prefix.join("TestCaskroom")
RSpec.configure do |config|
config.order = :random
+ config.include(Test::Helper::Env)
config.include(Test::Helper::Shutup)
end
diff --git a/Library/Homebrew/cask/spec/support/env_helper.rb b/Library/Homebrew/cask/spec/support/env_helper.rb
deleted file mode 100644
index 0a302ef45..000000000
--- a/Library/Homebrew/cask/spec/support/env_helper.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-module EnvHelper
- class << self
- def with_env_var(key, val)
- was_defined = ENV.key? "key"
- old_value = ENV["key"]
- ENV[key] = val
- yield
- ensure
- if was_defined
- ENV[key] = old_value
- else
- ENV.delete(key)
- end
- end
- end
-end