Skip to content
Snippets Groups Projects
Commit f717831a authored by Markus Reiter's avatar Markus Reiter
Browse files

Move Cask fixtures to `test/support/fixtures`.

parent 35045b29
No related branches found
No related tags found
No related merge requests found
Showing
with 64 additions and 66 deletions
......@@ -6,6 +6,7 @@ require "hbc/audit"
require "hbc/auditor"
require "hbc/cache"
require "hbc/cask"
require "hbc/cask_loader"
require "hbc/without_source"
require "hbc/caskroom"
require "hbc/checkable"
......
describe Hbc::Artifact::Binary do
let(:cask) {
Hbc.load("with-binary").tap do |cask|
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-binary.rb").tap do |cask|
shutup do
InstallHelper.install_without_artifacts(cask)
end
......@@ -69,7 +69,7 @@ describe Hbc::Artifact::Binary do
context "binary is inside an app package" do
let(:cask) {
Hbc.load("with-embedded-binary").tap do |cask|
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-embedded-binary.rb").tap do |cask|
shutup do
InstallHelper.install_without_artifacts(cask)
end
......
......@@ -32,7 +32,7 @@ Hbc.caskroom = Hbc.default_caskroom.tap(&:mkpath)
Hbc.default_tap = Tap.fetch("caskroom", "spec").tap do |tap|
# link test casks
FileUtils.mkdir_p tap.path.dirname
FileUtils.ln_s Pathname.new(__FILE__).dirname.join("support"), tap.path
FileUtils.ln_s TEST_FIXTURE_DIR.join("cask"), tap.path
end
RSpec.configure do |config|
......
......@@ -3,7 +3,7 @@ require "test_helper"
# TODO: this test should be named after the corresponding class, once
# that class is abstracted from installer.rb.
describe "Accessibility Access" do
let(:cask) { Hbc.load("with-accessibility-access") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-accessibility-access.rb") }
let(:with_fake_command) { { command: Hbc::FakeSystemCommand } }
let(:installer) { Hbc::Installer.new(cask, with_fake_command) }
......
......@@ -2,7 +2,7 @@ require "test_helper"
describe Hbc::Artifact::App do
describe "activate to alternate target" do
let(:cask) { Hbc.load("with-alt-target") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-alt-target.rb") }
let(:install_phase) {
-> { Hbc::Artifact::App.new(cask).install_phase }
......
require "test_helper"
describe Hbc::Artifact::App do
let(:cask) { Hbc.load("local-caffeine") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") }
let(:command) { Hbc::SystemCommand }
let(:force) { false }
let(:app) { Hbc::Artifact::App.new(cask, command: command, force: force) }
......
require "test_helper"
describe Hbc::Artifact::Artifact do
let(:cask) { Hbc.load("with-generic-artifact") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-generic-artifact.rb") }
let(:install_phase) {
-> { Hbc::Artifact::Artifact.new(cask).install_phase }
......@@ -15,7 +15,7 @@ describe Hbc::Artifact::Artifact do
end
describe "with no target" do
let(:cask) { Hbc.load("with-generic-artifact-no-target") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-generic-artifact-no-target.rb") }
it "fails to install with no target" do
install_phase.must_raise Hbc::CaskInvalidError
......
......@@ -3,7 +3,7 @@ require "test_helper"
describe Hbc::Artifact::NestedContainer do
describe "install" do
it "extracts the specified paths as containers" do
cask = Hbc.load("nested-app").tap do |c|
cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/nested-app.rb").tap do |c|
TestHelper.install_without_artifacts(c)
end
......
......@@ -2,7 +2,7 @@ require "test_helper"
describe Hbc::Artifact::Pkg do
before do
@cask = Hbc.load("with-installable")
@cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb")
shutup do
TestHelper.install_without_artifacts(@cask)
end
......@@ -33,7 +33,7 @@ describe Hbc::Artifact::Pkg do
describe "choices" do
before do
@cask = Hbc.load("with-choices")
@cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-choices.rb")
shutup do
TestHelper.install_without_artifacts(@cask)
end
......
require "test_helper"
describe Hbc::Artifact::Suite do
let(:cask) { Hbc.load("with-suite") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-suite.rb") }
let(:install_phase) { -> { Hbc::Artifact::Suite.new(cask).install_phase } }
......
......@@ -2,7 +2,7 @@ require "test_helper"
describe Hbc::Artifact::App do
describe "multiple apps" do
let(:cask) { Hbc.load("with-two-apps-correct") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-two-apps-correct.rb") }
let(:install_phase) {
-> { Hbc::Artifact::App.new(cask).install_phase }
......@@ -31,7 +31,7 @@ describe Hbc::Artifact::App do
end
describe "when apps are in a subdirectory" do
let(:cask) { Hbc.load("with-two-apps-subdir") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-two-apps-subdir.rb") }
it "installs both apps using the proper target directory" do
shutup do
......
require "test_helper"
describe Hbc::Artifact::App do
it "must raise" do
exception_raised = begin
Hbc.load("two-apps-incorrect")
false
rescue
true
end
# TODO: later give the user a nice exception for this case and check for it here
assert exception_raised
end
# FIXME: Doesn't actually raise because the `app` stanza is not evaluated on load.
# it "must raise" do
# lambda {
# Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-two-apps-incorrect.rb")
# }.must_raise
# # TODO: later give the user a nice exception for this case and check for it here
# end
end
require "test_helper"
describe Hbc::Artifact::Uninstall do
let(:cask) { Hbc.load("with-installable") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb") }
let(:uninstall_artifact) {
Hbc::Artifact::Uninstall.new(cask, command: Hbc::FakeSystemCommand)
......@@ -37,7 +37,7 @@ describe Hbc::Artifact::Uninstall do
end
describe "when using launchctl" do
let(:cask) { Hbc.load("with-uninstall-launchctl") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-launchctl.rb") }
let(:launchctl_list_cmd) { %w[/bin/launchctl list my.fancy.package.service] }
let(:launchctl_remove_cmd) { %w[/bin/launchctl remove my.fancy.package.service] }
let(:unknown_response) { "launchctl list returned unknown response\n" }
......@@ -94,7 +94,7 @@ describe Hbc::Artifact::Uninstall do
end
describe "when using pkgutil" do
let(:cask) { Hbc.load("with-uninstall-pkgutil") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-pkgutil.rb") }
let(:main_pkg_id) { "my.fancy.package.main" }
let(:agent_pkg_id) { "my.fancy.package.agent" }
let(:main_files) {
......@@ -180,7 +180,7 @@ describe Hbc::Artifact::Uninstall do
end
describe "when using kext" do
let(:cask) { Hbc.load("with-uninstall-kext") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-kext.rb") }
let(:kext_id) { "my.fancy.package.kernelextension" }
it "can uninstall" do
......@@ -205,7 +205,7 @@ describe Hbc::Artifact::Uninstall do
end
describe "when using quit" do
let(:cask) { Hbc.load("with-uninstall-quit") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-quit.rb") }
let(:bundle_id) { "my.fancy.package.app" }
let(:quit_application_script) {
%Q(tell application id "#{bundle_id}" to quit)
......@@ -225,7 +225,7 @@ describe Hbc::Artifact::Uninstall do
end
describe "when using signal" do
let(:cask) { Hbc.load("with-uninstall-signal") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-signal.rb") }
let(:bundle_id) { "my.fancy.package.app" }
let(:signals) { %w[TERM KILL] }
let(:unix_pids) { [12_345, 67_890] }
......@@ -244,7 +244,7 @@ describe Hbc::Artifact::Uninstall do
end
describe "when using delete" do
let(:cask) { Hbc.load("with-uninstall-delete") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-delete.rb") }
it "can uninstall" do
Hbc::FakeSystemCommand.expects_command(
......@@ -258,7 +258,7 @@ describe Hbc::Artifact::Uninstall do
end
describe "when using trash" do
let(:cask) { Hbc.load("with-uninstall-trash") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-trash.rb") }
it "can uninstall" do
Hbc::FakeSystemCommand.expects_command(
......@@ -272,7 +272,7 @@ describe Hbc::Artifact::Uninstall do
end
describe "when using rmdir" do
let(:cask) { Hbc.load("with-uninstall-rmdir") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-rmdir.rb") }
let(:dir_pathname) { Pathname.new("#{TEST_FIXTURE_DIR}/cask/empty_directory") }
it "can uninstall" do
......@@ -289,7 +289,7 @@ describe Hbc::Artifact::Uninstall do
end
describe "when using script" do
let(:cask) { Hbc.load("with-uninstall-script") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-script.rb") }
let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") }
it "can uninstall" do
......@@ -304,7 +304,7 @@ describe Hbc::Artifact::Uninstall do
end
describe "when using early_script" do
let(:cask) { Hbc.load("with-uninstall-early-script") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-early-script.rb") }
let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") }
it "can uninstall" do
......@@ -319,7 +319,7 @@ describe Hbc::Artifact::Uninstall do
end
describe "when using login_item" do
let(:cask) { Hbc.load("with-uninstall-login-item") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-login-item.rb") }
it "can uninstall" do
Hbc::FakeSystemCommand.expects_command(
......
......@@ -2,7 +2,7 @@ require "test_helper"
# TODO: test that zap removes an alternate version of the same Cask
describe Hbc::Artifact::Zap do
let(:cask) { Hbc.load("with-installable") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb") }
let(:zap_artifact) {
Hbc::Artifact::Zap.new(cask, command: Hbc::FakeSystemCommand)
......@@ -38,7 +38,7 @@ describe Hbc::Artifact::Zap do
end
describe "when using launchctl" do
let(:cask) { Hbc.load("with-zap-launchctl") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-launchctl.rb") }
let(:launchctl_list_cmd) { %w[/bin/launchctl list my.fancy.package.service] }
let(:launchctl_remove_cmd) { %w[/bin/launchctl remove my.fancy.package.service] }
let(:unknown_response) { "launchctl list returned unknown response\n" }
......@@ -95,7 +95,7 @@ describe Hbc::Artifact::Zap do
end
describe "when using pkgutil" do
let(:cask) { Hbc.load("with-zap-pkgutil") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-pkgutil.rb") }
let(:main_pkg_id) { "my.fancy.package.main" }
let(:agent_pkg_id) { "my.fancy.package.agent" }
let(:main_files) {
......@@ -181,7 +181,7 @@ describe Hbc::Artifact::Zap do
end
describe "when using kext" do
let(:cask) { Hbc.load("with-zap-kext") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-kext.rb") }
let(:kext_id) { "my.fancy.package.kernelextension" }
it "can zap" do
......@@ -206,7 +206,7 @@ describe Hbc::Artifact::Zap do
end
describe "when using quit" do
let(:cask) { Hbc.load("with-zap-quit") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-quit.rb") }
let(:bundle_id) { "my.fancy.package.app" }
let(:quit_application_script) {
%Q(tell application id "#{bundle_id}" to quit)
......@@ -226,7 +226,7 @@ describe Hbc::Artifact::Zap do
end
describe "when using signal" do
let(:cask) { Hbc.load("with-zap-signal") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-signal.rb") }
let(:bundle_id) { "my.fancy.package.app" }
let(:signals) { %w[TERM KILL] }
let(:unix_pids) { [12_345, 67_890] }
......@@ -245,7 +245,7 @@ describe Hbc::Artifact::Zap do
end
describe "when using delete" do
let(:cask) { Hbc.load("with-zap-delete") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-delete.rb") }
it "can zap" do
Hbc::FakeSystemCommand.expects_command(
......@@ -259,7 +259,7 @@ describe Hbc::Artifact::Zap do
end
describe "when using trash" do
let(:cask) { Hbc.load("with-zap-trash") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-trash.rb") }
it "can zap" do
Hbc::FakeSystemCommand.expects_command(
......@@ -273,7 +273,7 @@ describe Hbc::Artifact::Zap do
end
describe "when using rmdir" do
let(:cask) { Hbc.load("with-zap-rmdir") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-rmdir.rb") }
let(:dir_pathname) { Pathname.new("#{TEST_FIXTURE_DIR}/cask/empty_directory") }
it "can zap" do
......@@ -290,7 +290,7 @@ describe Hbc::Artifact::Zap do
end
describe "when using script" do
let(:cask) { Hbc.load("with-zap-script") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-script.rb") }
let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") }
it "can zap" do
......@@ -305,7 +305,7 @@ describe Hbc::Artifact::Zap do
end
describe "when using early_script" do
let(:cask) { Hbc.load("with-zap-early-script") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-early-script.rb") }
let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") }
it "can zap" do
......@@ -320,7 +320,7 @@ describe Hbc::Artifact::Zap do
end
describe "when using login_item" do
let(:cask) { Hbc.load("with-zap-login-item") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-login-item.rb") }
it "can zap" do
Hbc::FakeSystemCommand.expects_command(
......
......@@ -2,11 +2,11 @@ require "test_helper"
describe Hbc::CLI::Fetch do
let(:local_transmission) {
Hbc.load("local-transmission")
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")
}
let(:local_caffeine) {
Hbc.load("local-caffeine")
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
}
it "allows download the installer of a Cask" do
......
......@@ -6,9 +6,9 @@ describe Hbc::CLI::Install do
Hbc::CLI::Install.run("local-transmission", "local-caffeine")
end
Hbc.load("local-transmission").must_be :installed?
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb").must_be :installed?
Hbc.appdir.join("Transmission.app").must_be :directory?
Hbc.load("local-caffeine").must_be :installed?
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb").must_be :installed?
Hbc.appdir.join("Caffeine.app").must_be :directory?
end
......@@ -19,7 +19,7 @@ describe Hbc::CLI::Install do
shutup do
Hbc::CLI::Install.run("local-transmission")
end
Hbc.load("local-transmission").must_be :installed?
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb").must_be :installed?
end
it "prints a warning message on double install" do
......@@ -46,9 +46,9 @@ describe Hbc::CLI::Install do
shutup do
Hbc::CLI::Install.run("with-depends-on-cask-multiple", "--skip-cask-deps")
end
Hbc.load("with-depends-on-cask-multiple").must_be :installed?
Hbc.load("local-caffeine").wont_be :installed?
Hbc.load("local-transmission").wont_be :installed?
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask-multiple.rb").must_be :installed?
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb").wont_be :installed?
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb").wont_be :installed?
end
it "properly handles Casks that are not present" do
......
......@@ -64,8 +64,8 @@ describe Hbc::CLI::List do
end
describe "given a set of installed Casks" do
let(:caffeine) { Hbc.load("local-caffeine") }
let(:transmission) { Hbc.load("local-transmission") }
let(:caffeine) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") }
let(:transmission) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") }
let(:casks) { [caffeine, transmission] }
it "lists the installed files for those Casks" do
......
......@@ -5,20 +5,20 @@ describe Hbc::CLI::Reinstall do
shutup do
Hbc::CLI::Install.run("local-transmission")
end
Hbc.load("local-transmission").must_be :installed?
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb").must_be :installed?
shutup do
Hbc::CLI::Reinstall.run("local-transmission")
end
Hbc.load("local-transmission").must_be :installed?
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb").must_be :installed?
end
it "allows reinstalling a non installed Cask" do
Hbc.load("local-transmission").wont_be :installed?
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb").wont_be :installed?
shutup do
Hbc::CLI::Reinstall.run("local-transmission")
end
Hbc.load("local-transmission").must_be :installed?
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb").must_be :installed?
end
end
......@@ -20,8 +20,8 @@ describe Hbc::CLI::Uninstall do
end
it "can uninstall and unlink multiple Casks at once" do
caffeine = Hbc.load("local-caffeine")
transmission = Hbc.load("local-transmission")
caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")
shutup do
Hbc::Installer.new(caffeine).install
......
......@@ -8,8 +8,8 @@ describe Hbc::CLI::Zap do
end
it "can zap and unlink multiple Casks at once" do
caffeine = Hbc.load("local-caffeine")
transmission = Hbc.load("local-transmission")
caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")
shutup do
Hbc::Installer.new(caffeine).install
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment