Update Cask spec_helper.
This commit is contained in:
parent
e0e0233b2d
commit
551993a9c7
@ -1,32 +1,13 @@
|
|||||||
require "rspec/its"
|
|
||||||
require "rspec/wait"
|
|
||||||
|
|
||||||
if ENV["HOMEBREW_TESTS_COVERAGE"]
|
|
||||||
require "simplecov"
|
|
||||||
end
|
|
||||||
|
|
||||||
# add Homebrew to load path
|
|
||||||
$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew"))
|
$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew"))
|
||||||
$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew/test/support/lib"))
|
require "test/spec_helper"
|
||||||
|
|
||||||
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/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))
|
||||||
|
|
||||||
require "hbc"
|
require "hbc"
|
||||||
|
|
||||||
# create and override default directories
|
|
||||||
Hbc.default_tap = Tap.fetch("caskroom", "spec").tap do |tap|
|
|
||||||
# link test casks
|
|
||||||
FileUtils.mkdir_p tap.path.dirname
|
|
||||||
FileUtils.ln_s TEST_FIXTURE_DIR.join("cask"), tap.path
|
|
||||||
end
|
|
||||||
|
|
||||||
HOMEBREW_CASK_DIRS = [
|
HOMEBREW_CASK_DIRS = [
|
||||||
:appdir,
|
:appdir,
|
||||||
:caskroom,
|
:caskroom,
|
||||||
@ -38,26 +19,24 @@ HOMEBREW_CASK_DIRS = [
|
|||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.order = :random
|
|
||||||
config.include(Test::Helper::Shutup)
|
|
||||||
config.around(:each) do |example|
|
config.around(:each) do |example|
|
||||||
begin
|
begin
|
||||||
@__dirs = HOMEBREW_CASK_DIRS.map { |dir|
|
dirs = HOMEBREW_CASK_DIRS.map { |dir|
|
||||||
Pathname.new(TEST_TMPDIR).join(dir.to_s).tap { |path|
|
Pathname.new(TEST_TMPDIR).join("cask-#{dir}").tap { |path|
|
||||||
path.mkpath
|
path.mkpath
|
||||||
Hbc.public_send("#{dir}=", path)
|
Hbc.public_send("#{dir}=", path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@__argv = ARGV.dup
|
Hbc.default_tap = Tap.fetch("caskroom", "spec").tap do |tap|
|
||||||
@__env = ENV.to_hash # dup doesn't work on ENV
|
# link test casks
|
||||||
|
FileUtils.mkdir_p tap.path.dirname
|
||||||
|
FileUtils.ln_sf TEST_FIXTURE_DIR.join("cask"), tap.path
|
||||||
|
end
|
||||||
|
|
||||||
example.run
|
example.run
|
||||||
ensure
|
ensure
|
||||||
ARGV.replace(@__argv)
|
FileUtils.rm_rf dirs
|
||||||
ENV.replace(@__env)
|
|
||||||
|
|
||||||
FileUtils.rm_rf @__dirs.map(&:children)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user