tests: remove env helper
This commit is contained in:
parent
b7dc56a8aa
commit
62a0c3a6f5
@ -15,7 +15,6 @@ require "global"
|
|||||||
# add Homebrew-Cask to load path
|
# add Homebrew-Cask to load path
|
||||||
$LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.join("cask", "lib").to_s)
|
$LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.join("cask", "lib").to_s)
|
||||||
|
|
||||||
require "test/support/helper/env"
|
|
||||||
require "test/support/helper/shutup"
|
require "test/support/helper/shutup"
|
||||||
|
|
||||||
Pathname.glob(HOMEBREW_LIBRARY_PATH.join("cask", "spec", "support", "*.rb")).each(&method(:require))
|
Pathname.glob(HOMEBREW_LIBRARY_PATH.join("cask", "spec", "support", "*.rb")).each(&method(:require))
|
||||||
@ -38,6 +37,5 @@ end
|
|||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.order = :random
|
config.order = :random
|
||||||
config.include(Test::Helper::Env)
|
|
||||||
config.include(Test::Helper::Shutup)
|
config.include(Test::Helper::Shutup)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -19,8 +19,7 @@ class GPG2RequirementTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_satisfied
|
def test_satisfied
|
||||||
with_environment("PATH" => @dir/"bin") do
|
ENV["PATH"] = @dir/"bin"
|
||||||
assert_predicate GPG2Requirement.new, :satisfied?
|
assert_predicate GPG2Requirement.new, :satisfied?
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -10,10 +10,9 @@ class GpgTest < Homebrew::TestCase
|
|||||||
|
|
||||||
def test_create_test_key
|
def test_create_test_key
|
||||||
Dir.chdir(@dir) do
|
Dir.chdir(@dir) do
|
||||||
with_environment("HOME" => @dir) do
|
ENV["HOME"] = @dir
|
||||||
shutup { Gpg.create_test_key(@dir) }
|
shutup { Gpg.create_test_key(@dir) }
|
||||||
assert_predicate @dir/".gnupg/secring.gpg", :exist?
|
assert_predicate @dir/".gnupg/secring.gpg", :exist?
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,21 +0,0 @@
|
|||||||
module Test
|
|
||||||
module Helper
|
|
||||||
module Env
|
|
||||||
def copy_env
|
|
||||||
ENV.to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
def restore_env(env)
|
|
||||||
ENV.replace(env)
|
|
||||||
end
|
|
||||||
|
|
||||||
def with_environment(partial_env)
|
|
||||||
old = copy_env
|
|
||||||
ENV.update partial_env
|
|
||||||
yield
|
|
||||||
ensure
|
|
||||||
restore_env old
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@ -1,11 +1,9 @@
|
|||||||
module Homebrew
|
module Homebrew
|
||||||
class TestCase < ::Minitest::Test
|
class TestCase < ::Minitest::Test
|
||||||
require "test/support/helper/env"
|
|
||||||
require "test/support/helper/fs_leak_logger"
|
require "test/support/helper/fs_leak_logger"
|
||||||
require "test/support/helper/lifecycle_enforcer"
|
require "test/support/helper/lifecycle_enforcer"
|
||||||
require "test/support/helper/shutup"
|
require "test/support/helper/shutup"
|
||||||
require "test/support/helper/version_assertions"
|
require "test/support/helper/version_assertions"
|
||||||
include Test::Helper::Env
|
|
||||||
include Test::Helper::FSLeakLogger
|
include Test::Helper::FSLeakLogger
|
||||||
include Test::Helper::LifecycleEnforcer
|
include Test::Helper::LifecycleEnforcer
|
||||||
include Test::Helper::Shutup
|
include Test::Helper::Shutup
|
||||||
@ -18,12 +16,12 @@ module Homebrew
|
|||||||
super
|
super
|
||||||
|
|
||||||
@__argv = ARGV.dup
|
@__argv = ARGV.dup
|
||||||
@__env = copy_env
|
@__env = ENV.to_hash # dup doesn't work on ENV
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
ARGV.replace(@__argv)
|
ARGV.replace(@__argv)
|
||||||
restore_env @__env
|
ENV.replace(@__env)
|
||||||
|
|
||||||
Tab.clear_cache
|
Tab.clear_cache
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user