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

44 lines
1.1 KiB
Ruby
Raw Normal View History

2016-08-18 22:11:42 +03:00
require "pathname"
require "rspec/its"
require "rspec/wait"
2016-08-21 07:51:25 +02:00
if ENV["HOMEBREW_TESTS_COVERAGE"]
require "simplecov"
2016-08-18 22:11:42 +03:00
end
# add Homebrew to load path
2016-09-20 15:11:33 +02:00
$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew"))
2016-10-19 23:01:52 +02:00
$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew/test/lib"))
2016-08-18 22:11:42 +03:00
require "global"
# 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
require "test/helper/env"
2016-08-21 04:48:35 +02:00
require "test/helper/shutup"
2016-10-19 23:01:52 +02:00
Pathname.glob(HOMEBREW_LIBRARY_PATH.join("cask", "spec", "support", "*.rb")).each(&method(:require))
2016-08-18 22:11:42 +03:00
require "hbc"
2016-09-24 13:52:43 +02:00
module Hbc
class TestCask < Cask; end
end
2016-08-18 22:11:42 +03:00
2016-10-19 23:01:52 +02:00
# create and override default directories
Hbc.appdir = Pathname.new(TEST_TMPDIR).join("Applications").tap(&:mkpath)
2016-08-18 22:11:42 +03:00
Hbc.cache.mkpath
2016-10-19 23:01:52 +02:00
Hbc.caskroom.mkpath
Hbc.default_tap = Tap.fetch("caskroom", "spec").tap do |tap|
tap.path.dirname.mkpath
end
2016-08-18 22:11:42 +03:00
2016-10-19 23:01:52 +02:00
FileUtils.ln_s Pathname.new(__FILE__).dirname.join("support"), Hbc.default_tap.path
2016-08-18 22:11:42 +03:00
RSpec.configure do |config|
config.order = :random
config.include(Test::Helper::Env)
2016-08-21 04:48:35 +02:00
config.include(Test::Helper::Shutup)
2016-08-18 22:11:42 +03:00
end