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
|
||||
$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
|
||||
|
||||
@ -19,8 +19,7 @@ class GPG2RequirementTests < Homebrew::TestCase
|
||||
end
|
||||
|
||||
def test_satisfied
|
||||
with_environment("PATH" => @dir/"bin") do
|
||||
assert_predicate GPG2Requirement.new, :satisfied?
|
||||
end
|
||||
ENV["PATH"] = @dir/"bin"
|
||||
assert_predicate GPG2Requirement.new, :satisfied?
|
||||
end
|
||||
end
|
||||
|
||||
@ -10,10 +10,9 @@ class GpgTest < Homebrew::TestCase
|
||||
|
||||
def test_create_test_key
|
||||
Dir.chdir(@dir) do
|
||||
with_environment("HOME" => @dir) do
|
||||
shutup { Gpg.create_test_key(@dir) }
|
||||
assert_predicate @dir/".gnupg/secring.gpg", :exist?
|
||||
end
|
||||
ENV["HOME"] = @dir
|
||||
shutup { Gpg.create_test_key(@dir) }
|
||||
assert_predicate @dir/".gnupg/secring.gpg", :exist?
|
||||
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
|
||||
class TestCase < ::Minitest::Test
|
||||
require "test/support/helper/env"
|
||||
require "test/support/helper/fs_leak_logger"
|
||||
require "test/support/helper/lifecycle_enforcer"
|
||||
require "test/support/helper/shutup"
|
||||
require "test/support/helper/version_assertions"
|
||||
include Test::Helper::Env
|
||||
include Test::Helper::FSLeakLogger
|
||||
include Test::Helper::LifecycleEnforcer
|
||||
include Test::Helper::Shutup
|
||||
@ -18,12 +16,12 @@ module Homebrew
|
||||
super
|
||||
|
||||
@__argv = ARGV.dup
|
||||
@__env = copy_env
|
||||
@__env = ENV.to_hash # dup doesn't work on ENV
|
||||
end
|
||||
|
||||
def teardown
|
||||
ARGV.replace(@__argv)
|
||||
restore_env @__env
|
||||
ENV.replace(@__env)
|
||||
|
||||
Tab.clear_cache
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user