brew/Library/Homebrew/cask/spec/spec_helper.rb

43 lines
1018 B
Ruby
Raw Normal View History

2016-09-20 15:11:33 +02:00
$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew"))
2017-03-05 04:28:14 +01:00
require "test/spec_helper"
2016-08-18 22:11:42 +03:00
# add Homebrew-Cask to load path
2016-10-19 23:01:52 +02:00
$LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.join("cask", "lib").to_s)
2016-08-18 22:11:42 +03:00
2017-02-09 03:49:12 +01:00
Pathname.glob(HOMEBREW_LIBRARY_PATH.join("cask", "spec", "support", "**", "*.rb")).each(&method(:require))
2016-08-18 22:11:42 +03:00
require "hbc"
2017-02-09 04:37:24 +01:00
HOMEBREW_CASK_DIRS = [
:appdir,
:caskroom,
2017-03-04 20:02:40 +01:00
:cache,
2017-02-09 04:37:24 +01:00
:prefpanedir,
:qlplugindir,
:servicedir,
:binarydir,
].freeze
2016-08-18 22:11:42 +03:00
RSpec.configure do |config|
2017-02-08 13:25:10 +01:00
config.around(:each) do |example|
begin
2017-03-05 04:28:14 +01:00
dirs = HOMEBREW_CASK_DIRS.map { |dir|
Pathname.new(TEST_TMPDIR).join("cask-#{dir}").tap { |path|
2017-02-09 04:37:24 +01:00
path.mkpath
Hbc.public_send("#{dir}=", path)
}
}
2017-02-08 13:25:10 +01:00
2017-03-05 04:28:14 +01:00
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
2017-02-08 13:25:10 +01:00
example.run
ensure
2017-03-05 04:28:14 +01:00
FileUtils.rm_rf dirs
2017-02-08 13:25:10 +01:00
end
2017-02-08 08:29:41 +01:00
end
2016-08-18 22:11:42 +03:00
end