aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/support
diff options
context:
space:
mode:
authorMarkus Reiter2017-03-05 06:31:36 +0100
committerMarkus Reiter2017-03-05 23:08:14 +0100
commit9fc6c7b2be300ff35dc52d80f4dc38d36d52ddc2 (patch)
tree43e99a683329471c1dc965dcc92daccb57df7e8d /Library/Homebrew/test/support
parent67ec76d1492fbb03959a782a85c4fb985d6a5884 (diff)
downloadbrew-9fc6c7b2be300ff35dc52d80f4dc38d36d52ddc2.tar.bz2
Move Cask specs into `brew tests`.
Diffstat (limited to 'Library/Homebrew/test/support')
-rw-r--r--Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb b/Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb
new file mode 100644
index 000000000..c51d339a7
--- /dev/null
+++ b/Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb
@@ -0,0 +1,45 @@
+$LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.join("cask", "lib").to_s)
+
+require "hbc"
+
+require "test/support/helper/cask/fake_system_command"
+require "test/support/helper/cask/install_helper"
+require "test/support/helper/cask/never_sudo_system_command"
+
+HOMEBREW_CASK_DIRS = [
+ :appdir,
+ :caskroom,
+ :cache,
+ :prefpanedir,
+ :qlplugindir,
+ :servicedir,
+ :binarydir,
+].freeze
+
+RSpec.shared_context "Homebrew-Cask" do
+ around(:each) do |example|
+ begin
+ dirs = HOMEBREW_CASK_DIRS.map do |dir|
+ Pathname.new(TEST_TMPDIR).join("cask-#{dir}").tap do |path|
+ path.mkpath
+ Hbc.public_send("#{dir}=", path)
+ end
+ end
+
+ Hbc.default_tap = Tap.fetch("caskroom", "spec").tap do |tap|
+ FileUtils.mkdir_p tap.path.dirname
+ FileUtils.ln_sf TEST_FIXTURE_DIR.join("cask"), tap.path
+ end
+
+ example.run
+ ensure
+ FileUtils.rm_rf dirs
+ Hbc.default_tap.path.unlink
+ FileUtils.rm_rf Hbc.default_tap.path.parent
+ end
+ end
+end
+
+RSpec.configure do |config|
+ config.include_context "Homebrew-Cask", :cask
+end