aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/support
diff options
context:
space:
mode:
authorMarkus Reiter2017-03-05 23:31:21 +0100
committerGitHub2017-03-05 23:31:21 +0100
commit1fbd720e3558934f8050385e31e1fec4e7ead982 (patch)
tree13d5867932f5b61ce16335e2bb04ab428ba76f77 /Library/Homebrew/test/support
parent67ec76d1492fbb03959a782a85c4fb985d6a5884 (diff)
parenteed5a69a51966f53068af7117483f9fd681346fa (diff)
downloadbrew-1fbd720e3558934f8050385e31e1fec4e7ead982.tar.bz2
Merge pull request #2260 from reitermarkus/spec-cask
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