aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Hagins2016-10-19 14:08:27 -0400
committerGitHub2016-10-19 14:08:27 -0400
commitde5cadc44797bb9af38c2c89231f0657a9bf3538 (patch)
tree2e99e54c1f134ce472438d7daf6d6e4fbcd3cc12
parentc18441e81b19da61e87eb3c4af8d5cef44c9c0ae (diff)
parenteebf535beee726ccbbeeb756ade86f216a0fcbc0 (diff)
downloadbrew-de5cadc44797bb9af38c2c89231f0657a9bf3538.tar.bz2
Merge pull request #1328 from jawshooah/cask/fix-tests
Unset HOMEBREW_DEVELOPER in cask tests likely to raise deprecation errors
-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
-rw-r--r--Library/Homebrew/cask/test/Casks/compliance_test.rb16
-rw-r--r--Library/Homebrew/cask/test/cask/dsl_test.rb12
-rw-r--r--Library/Homebrew/cask/test/test_helper.rb2
-rw-r--r--Library/Homebrew/test/helper/env.rb15
-rw-r--r--Library/Homebrew/test/testing_env.rb12
8 files changed, 39 insertions, 40 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
diff --git a/Library/Homebrew/cask/test/Casks/compliance_test.rb b/Library/Homebrew/cask/test/Casks/compliance_test.rb
index fff3e0798..1ab5819ed 100644
--- a/Library/Homebrew/cask/test/Casks/compliance_test.rb
+++ b/Library/Homebrew/cask/test/Casks/compliance_test.rb
@@ -1,13 +1,15 @@
require 'test_helper'
describe "Casks" do
- Hbc.all.reject {|c| c.is_a?(Hbc::TestCask) }.each do |cask|
- describe "#{cask}" do
- it "passes audit" do
- audit = Hbc::Audit.new(cask)
- audit.run!
- audit.errors.must_equal [], "[#{cask}] Cask audit must be error free"
- audit.warnings.must_equal [], "[#{cask}] Cask audit must be warning free"
+ with_environment "HOMEBREW_DEVELOPER" => nil do
+ Hbc.all.reject {|c| c.is_a?(Hbc::TestCask) }.each do |cask|
+ describe "#{cask}" do
+ it "passes audit" do
+ audit = Hbc::Audit.new(cask)
+ audit.run!
+ audit.errors.must_equal [], "[#{cask}] Cask audit must be error free"
+ audit.warnings.must_equal [], "[#{cask}] Cask audit must be warning free"
+ end
end
end
end
diff --git a/Library/Homebrew/cask/test/cask/dsl_test.rb b/Library/Homebrew/cask/test/cask/dsl_test.rb
index 2d51a20f1..ecd1cb72f 100644
--- a/Library/Homebrew/cask/test/cask/dsl_test.rb
+++ b/Library/Homebrew/cask/test/cask/dsl_test.rb
@@ -69,11 +69,13 @@ describe Hbc::DSL do
end
it "may use deprecated DSL version hash syntax" do
- test_cask = Hbc.load("with-dsl-version")
- test_cask.token.must_equal "with-dsl-version"
- test_cask.url.to_s.must_equal "http://example.com/TestCask.dmg"
- test_cask.homepage.must_equal "http://example.com/"
- test_cask.version.to_s.must_equal "1.2.3"
+ with_environment "HOMEBREW_DEVELOPER" => nil do
+ test_cask = Hbc.load("with-dsl-version")
+ test_cask.token.must_equal "with-dsl-version"
+ test_cask.url.to_s.must_equal "http://example.com/TestCask.dmg"
+ test_cask.homepage.must_equal "http://example.com/"
+ test_cask.version.to_s.must_equal "1.2.3"
+ end
end
end
diff --git a/Library/Homebrew/cask/test/test_helper.rb b/Library/Homebrew/cask/test/test_helper.rb
index 25b32d2de..8f5e25777 100644
--- a/Library/Homebrew/cask/test/test_helper.rb
+++ b/Library/Homebrew/cask/test/test_helper.rb
@@ -17,7 +17,9 @@ 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"
+include Test::Helper::Env
include Test::Helper::Shutup
def sudo(*args)
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
diff --git a/Library/Homebrew/test/testing_env.rb b/Library/Homebrew/test/testing_env.rb
index 02264aa39..5f98ace15 100644
--- a/Library/Homebrew/test/testing_env.rb
+++ b/Library/Homebrew/test/testing_env.rb
@@ -63,7 +63,9 @@ module Homebrew
end
class TestCase < ::Minitest::Test
+ require "test/helper/env"
require "test/helper/shutup"
+ include Test::Helper::Env
include Test::Helper::Shutup
include VersionAssertions
@@ -112,16 +114,6 @@ module Homebrew
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
-
# Use a stubbed {Formulary::FormulaLoader} to make a given formula be found
# when loading from {Formulary} with `ref`.
def stub_formula_loader(formula, ref = formula.full_name)