From 551993a9c79912ed48c3d649414eb1e6d1b980b0 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 5 Mar 2017 04:28:14 +0100 Subject: [PATCH] Update Cask `spec_helper`. --- Library/Homebrew/cask/spec/spec_helper.rb | 39 ++++++----------------- 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/Library/Homebrew/cask/spec/spec_helper.rb b/Library/Homebrew/cask/spec/spec_helper.rb index 985a5335f6..ca0b69d33d 100644 --- a/Library/Homebrew/cask/spec/spec_helper.rb +++ b/Library/Homebrew/cask/spec/spec_helper.rb @@ -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/test/support/lib")) - -require "global" +require "test/spec_helper" # add Homebrew-Cask to load path $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)) 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 = [ :appdir, :caskroom, @@ -38,26 +19,24 @@ HOMEBREW_CASK_DIRS = [ ].freeze RSpec.configure do |config| - config.order = :random - config.include(Test::Helper::Shutup) config.around(:each) do |example| begin - @__dirs = HOMEBREW_CASK_DIRS.map { |dir| - Pathname.new(TEST_TMPDIR).join(dir.to_s).tap { |path| + dirs = HOMEBREW_CASK_DIRS.map { |dir| + Pathname.new(TEST_TMPDIR).join("cask-#{dir}").tap { |path| path.mkpath Hbc.public_send("#{dir}=", path) } } - @__argv = ARGV.dup - @__env = ENV.to_hash # dup doesn't work on ENV + Hbc.default_tap = Tap.fetch("caskroom", "spec").tap do |tap| + # link test casks + FileUtils.mkdir_p tap.path.dirname + FileUtils.ln_sf TEST_FIXTURE_DIR.join("cask"), tap.path + end example.run ensure - ARGV.replace(@__argv) - ENV.replace(@__env) - - FileUtils.rm_rf @__dirs.map(&:children) + FileUtils.rm_rf dirs end end end