testing_env: extract with_environment to helper module
This commit is contained in:
parent
b9fe36abdc
commit
fba00f2bbf
15
Library/Homebrew/test/helper/env.rb
Normal file
15
Library/Homebrew/test/helper/env.rb
Normal file
@ -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
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user