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

52 lines
1.3 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"))
$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew/test/support/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/support/helper/shutup"
2016-08-21 04:48:35 +02:00
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-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
Hbc.caskroom = Hbc.default_caskroom.tap(&:mkpath)
2016-10-19 23:01:52 +02:00
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
2016-10-19 23:01:52 +02:00
end
2016-08-18 22:11:42 +03:00
RSpec.configure do |config|
config.order = :random
2016-08-21 04:48:35 +02:00
config.include(Test::Helper::Shutup)
2017-02-08 08:29:41 +01:00
config.after(:each) do
FileUtils.rm_rf [
Hbc.appdir.children,
Hbc.caskroom.children,
]
end
2016-08-18 22:11:42 +03:00
end
2017-02-08 09:58:38 +01:00
module Hbc
class NeverSudoSystemCommand < SystemCommand
def self.run(command, options = {})
super(command, options.merge(sudo: false))
end
end
end