aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask
diff options
context:
space:
mode:
authorMarkus Reiter2017-03-04 22:59:13 +0100
committerMarkus Reiter2017-03-05 00:57:34 +0100
commitcc4fb35ae46fbbdeabbc564cae09507450838070 (patch)
tree6c64ebdc362f996fa51fdae5755f6602383d4c66 /Library/Homebrew/cask
parentf84ad9ca2ea0e86a2ba43c8b4b9cdffd0a707f5a (diff)
downloadbrew-cc4fb35ae46fbbdeabbc564cae09507450838070.tar.bz2
Move Cask `shared_examples` to `test/support`.
Diffstat (limited to 'Library/Homebrew/cask')
-rw-r--r--Library/Homebrew/cask/spec/cask/dsl/caveats_spec.rb1
-rw-r--r--Library/Homebrew/cask/spec/cask/dsl/postflight_spec.rb2
-rw-r--r--Library/Homebrew/cask/spec/cask/dsl/preflight_spec.rb2
-rw-r--r--Library/Homebrew/cask/spec/cask/dsl/uninstall_postflight_spec.rb1
-rw-r--r--Library/Homebrew/cask/spec/cask/dsl/uninstall_preflight_spec.rb2
-rw-r--r--Library/Homebrew/cask/spec/support/shared_examples/dsl_base.rb23
-rw-r--r--Library/Homebrew/cask/spec/support/shared_examples/staged.rb143
7 files changed, 8 insertions, 166 deletions
diff --git a/Library/Homebrew/cask/spec/cask/dsl/caveats_spec.rb b/Library/Homebrew/cask/spec/cask/dsl/caveats_spec.rb
index 777491d66..07940cd0a 100644
--- a/Library/Homebrew/cask/spec/cask/dsl/caveats_spec.rb
+++ b/Library/Homebrew/cask/spec/cask/dsl/caveats_spec.rb
@@ -1,4 +1,5 @@
require "spec_helper"
+require "test/support/helper/spec/shared_examples/hbc_dsl_base"
describe Hbc::DSL::Caveats do
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
diff --git a/Library/Homebrew/cask/spec/cask/dsl/postflight_spec.rb b/Library/Homebrew/cask/spec/cask/dsl/postflight_spec.rb
index 116a7c8a8..d7a8f219d 100644
--- a/Library/Homebrew/cask/spec/cask/dsl/postflight_spec.rb
+++ b/Library/Homebrew/cask/spec/cask/dsl/postflight_spec.rb
@@ -1,4 +1,6 @@
require "spec_helper"
+require "test/support/helper/spec/shared_examples/hbc_dsl_base"
+require "test/support/helper/spec/shared_examples/hbc_staged"
describe Hbc::DSL::Postflight do
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
diff --git a/Library/Homebrew/cask/spec/cask/dsl/preflight_spec.rb b/Library/Homebrew/cask/spec/cask/dsl/preflight_spec.rb
index 90d2634db..81b0c7975 100644
--- a/Library/Homebrew/cask/spec/cask/dsl/preflight_spec.rb
+++ b/Library/Homebrew/cask/spec/cask/dsl/preflight_spec.rb
@@ -1,4 +1,6 @@
require "spec_helper"
+require "test/support/helper/spec/shared_examples/hbc_dsl_base"
+require "test/support/helper/spec/shared_examples/hbc_staged"
describe Hbc::DSL::Preflight do
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
diff --git a/Library/Homebrew/cask/spec/cask/dsl/uninstall_postflight_spec.rb b/Library/Homebrew/cask/spec/cask/dsl/uninstall_postflight_spec.rb
index 4b7dd7557..448e1b411 100644
--- a/Library/Homebrew/cask/spec/cask/dsl/uninstall_postflight_spec.rb
+++ b/Library/Homebrew/cask/spec/cask/dsl/uninstall_postflight_spec.rb
@@ -1,4 +1,5 @@
require "spec_helper"
+require "test/support/helper/spec/shared_examples/hbc_dsl_base"
describe Hbc::DSL::UninstallPostflight do
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
diff --git a/Library/Homebrew/cask/spec/cask/dsl/uninstall_preflight_spec.rb b/Library/Homebrew/cask/spec/cask/dsl/uninstall_preflight_spec.rb
index a4930e99e..aac34e76a 100644
--- a/Library/Homebrew/cask/spec/cask/dsl/uninstall_preflight_spec.rb
+++ b/Library/Homebrew/cask/spec/cask/dsl/uninstall_preflight_spec.rb
@@ -1,4 +1,6 @@
require "spec_helper"
+require "test/support/helper/spec/shared_examples/hbc_dsl_base"
+require "test/support/helper/spec/shared_examples/hbc_staged"
describe Hbc::DSL::UninstallPreflight do
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
diff --git a/Library/Homebrew/cask/spec/support/shared_examples/dsl_base.rb b/Library/Homebrew/cask/spec/support/shared_examples/dsl_base.rb
deleted file mode 100644
index 400ff40f6..000000000
--- a/Library/Homebrew/cask/spec/support/shared_examples/dsl_base.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require "hbc/dsl/base"
-
-shared_examples Hbc::DSL::Base do
- it "supports the token method" do
- expect(dsl.token).to eq(cask.token)
- end
-
- it "supports the version method" do
- expect(dsl.version).to eq(cask.version)
- end
-
- it "supports the caskroom_path method" do
- expect(dsl.caskroom_path).to eq(cask.caskroom_path)
- end
-
- it "supports the staged_path method" do
- expect(dsl.staged_path).to eq(cask.staged_path)
- end
-
- it "supports the appdir method" do
- expect(dsl.appdir).to eq(cask.appdir)
- end
-end
diff --git a/Library/Homebrew/cask/spec/support/shared_examples/staged.rb b/Library/Homebrew/cask/spec/support/shared_examples/staged.rb
deleted file mode 100644
index d815ef7a0..000000000
--- a/Library/Homebrew/cask/spec/support/shared_examples/staged.rb
+++ /dev/null
@@ -1,143 +0,0 @@
-require "spec_helper"
-
-require "hbc/staged"
-
-shared_examples Hbc::Staged do
- let(:fake_pathname_exists) {
- fake_pathname = Pathname.new("/path/to/file/that/exists")
- allow(fake_pathname).to receive(:exist?).and_return(true)
- allow(fake_pathname).to receive(:expand_path).and_return(fake_pathname)
- fake_pathname
- }
-
- let(:fake_pathname_does_not_exist) {
- fake_pathname = Pathname.new("/path/to/file/that/does/not/exist")
- allow(fake_pathname).to receive(:exist?).and_return(false)
- allow(fake_pathname).to receive(:expand_path).and_return(fake_pathname)
- fake_pathname
- }
-
- it "can run system commands with list-form arguments" do
- Hbc::FakeSystemCommand.expects_command(
- ["echo", "homebrew-cask", "rocks!"],
- )
-
- shutup do
- staged.system_command("echo", args: ["homebrew-cask", "rocks!"])
- end
- end
-
- it "can get the Info.plist file for the primary app" do
- expect(staged.info_plist_file.to_s).to include Hbc.appdir.join("TestCask.app/Contents/Info.plist")
- end
-
- it "can execute commands on the Info.plist file" do
- allow(staged).to receive(:bundle_identifier).and_return("com.example.BasicCask")
-
- Hbc::FakeSystemCommand.expects_command(
- ["/usr/libexec/PlistBuddy", "-c", "Print CFBundleIdentifier", staged.info_plist_file],
- )
-
- shutup do
- staged.plist_exec("Print CFBundleIdentifier")
- end
- end
-
- it "can set a key in the Info.plist file" do
- allow(staged).to receive(:bundle_identifier).and_return("com.example.BasicCask")
-
- Hbc::FakeSystemCommand.expects_command(
- ["/usr/libexec/PlistBuddy", "-c", "Set :JVMOptions:JVMVersion 1.6+", staged.info_plist_file],
- )
-
- shutup do
- staged.plist_set(":JVMOptions:JVMVersion", "1.6+")
- end
- end
-
- it "can set the permissions of a file" do
- fake_pathname = fake_pathname_exists
- allow(staged).to receive(:Pathname).and_return(fake_pathname)
-
- Hbc::FakeSystemCommand.expects_command(
- ["/bin/chmod", "-R", "--", "777", fake_pathname],
- )
-
- shutup do
- staged.set_permissions(fake_pathname.to_s, "777")
- end
- end
-
- it "can set the permissions of multiple files" do
- fake_pathname = fake_pathname_exists
- allow(staged).to receive(:Pathname).and_return(fake_pathname)
-
- Hbc::FakeSystemCommand.expects_command(
- ["/bin/chmod", "-R", "--", "777", fake_pathname, fake_pathname],
- )
-
- shutup do
- staged.set_permissions([fake_pathname.to_s, fake_pathname.to_s], "777")
- end
- end
-
- it "cannot set the permissions of a file that does not exist" do
- fake_pathname = fake_pathname_does_not_exist
- allow(staged).to receive(:Pathname).and_return(fake_pathname)
- staged.set_permissions(fake_pathname.to_s, "777")
- end
-
- it "can set the ownership of a file" do
- fake_pathname = fake_pathname_exists
-
- allow(staged).to receive(:current_user).and_return("fake_user")
- allow(staged).to receive(:Pathname).and_return(fake_pathname)
-
- Hbc::FakeSystemCommand.expects_command(
- ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname],
- )
-
- shutup do
- staged.set_ownership(fake_pathname.to_s)
- end
- end
-
- it "can set the ownership of multiple files" do
- fake_pathname = fake_pathname_exists
-
- allow(staged).to receive(:current_user).and_return("fake_user")
- allow(staged).to receive(:Pathname).and_return(fake_pathname)
-
- Hbc::FakeSystemCommand.expects_command(
- ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "fake_user:staff", fake_pathname, fake_pathname],
- )
-
- shutup do
- staged.set_ownership([fake_pathname.to_s, fake_pathname.to_s])
- end
- end
-
- it "can set the ownership of a file with a different user and group" do
- fake_pathname = fake_pathname_exists
-
- allow(staged).to receive(:Pathname).and_return(fake_pathname)
-
- Hbc::FakeSystemCommand.expects_command(
- ["/usr/bin/sudo", "-E", "--", "/usr/sbin/chown", "-R", "--", "other_user:other_group", fake_pathname],
- )
-
- shutup do
- staged.set_ownership(fake_pathname.to_s, user: "other_user", group: "other_group")
- end
- end
-
- it "cannot set the ownership of a file that does not exist" do
- allow(staged).to receive(:current_user).and_return("fake_user")
- fake_pathname = fake_pathname_does_not_exist
- allow(staged).to receive(:Pathname).and_return(fake_pathname)
-
- shutup do
- staged.set_ownership(fake_pathname.to_s)
- end
- end
-end