Move Cask fixtures to test/support/fixtures.

This commit is contained in:
Markus Reiter 2016-12-06 16:36:34 +01:00
parent 35045b2934
commit f717831a03
165 changed files with 158 additions and 160 deletions

View File

@ -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"

View File

@ -1,6 +1,6 @@
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

View File

@ -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|

View File

@ -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) }

View File

@ -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 }

View File

@ -1,7 +1,7 @@
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) }

View File

@ -1,7 +1,7 @@
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

View File

@ -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

View File

@ -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

View File

@ -1,7 +1,7 @@
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 } }

View File

@ -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

View File

@ -1,14 +1,11 @@
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

View File

@ -1,7 +1,7 @@
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(

View File

@ -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(

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -3,7 +3,7 @@ require "test_helper"
describe Hbc::Container::Dmg do
describe "mount!" do
it "does not store nil mounts for dmgs with extra data" do
transmission = Hbc.load("local-transmission")
transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")
dmg = Hbc::Container::Dmg.new(
transmission,

View File

@ -13,7 +13,7 @@ describe "Satisfy Dependencies and Requirements" do
describe "depends_on cask" do
it "raises an exception when depends_on cask is cyclic" do
dep_cask = Hbc.load("with-depends-on-cask-cyclic")
dep_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask-cyclic.rb")
lambda {
shutup do
Hbc::Installer.new(dep_cask).install
@ -22,7 +22,7 @@ describe "Satisfy Dependencies and Requirements" do
end
it "installs the dependency of a Cask and the Cask itself" do
csk = Hbc.load("with-depends-on-cask")
csk = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask.rb")
dependency = Hbc.load(csk.depends_on.cask.first)
shutup do
Hbc::Installer.new(csk).install
@ -35,35 +35,35 @@ describe "Satisfy Dependencies and Requirements" do
describe "depends_on macos" do
it "understands depends_on macos: <array>" do
macos_cask = Hbc.load("with-depends-on-macos-array")
macos_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-array.rb")
shutup do
Hbc::Installer.new(macos_cask).install
end
end
it "understands depends_on macos: <comparison>" do
macos_cask = Hbc.load("with-depends-on-macos-comparison")
macos_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-comparison.rb")
shutup do
Hbc::Installer.new(macos_cask).install
end
end
it "understands depends_on macos: <string>" do
macos_cask = Hbc.load("with-depends-on-macos-string")
macos_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-string.rb")
shutup do
Hbc::Installer.new(macos_cask).install
end
end
it "understands depends_on macos: <symbol>" do
macos_cask = Hbc.load("with-depends-on-macos-symbol")
macos_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-symbol.rb")
shutup do
Hbc::Installer.new(macos_cask).install
end
end
it "raises an exception when depends_on macos is not satisfied" do
macos_cask = Hbc.load("with-depends-on-macos-failure")
macos_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-failure.rb")
lambda {
shutup do
Hbc::Installer.new(macos_cask).install
@ -74,7 +74,7 @@ describe "Satisfy Dependencies and Requirements" do
describe "depends_on arch" do
it "succeeds when depends_on arch is satisfied" do
arch_cask = Hbc.load("with-depends-on-arch")
arch_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-arch.rb")
shutup do
Hbc::Installer.new(arch_cask).install
end
@ -83,7 +83,7 @@ describe "Satisfy Dependencies and Requirements" do
describe "depends_on x11" do
it "succeeds when depends_on x11 is satisfied" do
x11_cask = Hbc.load("with-depends-on-x11")
x11_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-x11.rb")
MacOS::X11.stubs(:installed?).returns(true)
shutup do
Hbc::Installer.new(x11_cask).install
@ -91,7 +91,7 @@ describe "Satisfy Dependencies and Requirements" do
end
it "raises an exception when depends_on x11 is not satisfied" do
x11_cask = Hbc.load("with-depends-on-x11")
x11_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-x11.rb")
MacOS::X11.stubs(:installed?).returns(false)
lambda {
shutup do
@ -101,7 +101,7 @@ describe "Satisfy Dependencies and Requirements" do
end
it "never raises when depends_on x11: false" do
x11_cask = Hbc.load("with-depends-on-x11-false")
x11_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-x11-false.rb")
MacOS::X11.stubs(:installed?).returns(false)
lambda do
shutup do

View File

@ -1,7 +1,7 @@
require "test_helper"
describe Hbc::DSL::Caveats do
let(:cask) { Hbc.load("basic-cask") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
let(:dsl) { Hbc::DSL::Caveats.new(cask) }
it_behaves_like Hbc::DSL::Base

View File

@ -1,7 +1,7 @@
require "test_helper"
describe Hbc::DSL::Postflight do
let(:cask) { Hbc.load("basic-cask") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
let(:dsl) { Hbc::DSL::Postflight.new(cask, Hbc::FakeSystemCommand) }
it_behaves_like Hbc::DSL::Base

View File

@ -1,7 +1,7 @@
require "test_helper"
describe Hbc::DSL::Preflight do
let(:cask) { Hbc.load("basic-cask") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
let(:dsl) { Hbc::DSL::Preflight.new(cask, Hbc::FakeSystemCommand) }
it_behaves_like Hbc::DSL::Base

View File

@ -1,7 +1,7 @@
require "test_helper"
describe Hbc::DSL::UninstallPostflight do
let(:cask) { Hbc.load("basic-cask") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
let(:dsl) { Hbc::DSL::UninstallPostflight.new(cask, Hbc::FakeSystemCommand) }
it_behaves_like Hbc::DSL::Base

View File

@ -1,7 +1,7 @@
require "test_helper"
describe Hbc::DSL::UninstallPreflight do
let(:cask) { Hbc.load("basic-cask") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
let(:dsl) { Hbc::DSL::UninstallPreflight.new(cask, Hbc::FakeSystemCommand) }
it_behaves_like Hbc::DSL::Base

View File

@ -2,7 +2,7 @@ require "test_helper"
describe Hbc::DSL do
it "lets you set url, homepage, and version" do
test_cask = Hbc.load("basic-cask")
test_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb")
test_cask.url.to_s.must_equal "http://example.com/TestCask.dmg"
test_cask.homepage.must_equal "http://example.com/"
test_cask.version.to_s.must_equal "1.2.3"
@ -48,20 +48,20 @@ describe Hbc::DSL do
describe "header line" do
it "requires a valid header format" do
lambda {
Hbc.load("invalid/invalid-header-format")
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-header-format.rb")
}.must_raise(SyntaxError)
end
it "requires the header token to match the file name" do
err = lambda {
Hbc.load("invalid/invalid-header-token-mismatch")
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-header-token-mismatch.rb")
}.must_raise(Hbc::CaskTokenDoesNotMatchError)
err.message.must_include "Bad header line:"
err.message.must_include "does not match file name"
end
it "does not require a DSL version in the header" do
test_cask = Hbc.load("no-dsl-version")
test_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-dsl-version.rb")
test_cask.token.must_equal "no-dsl-version"
test_cask.url.to_s.must_equal "http://example.com/TestCask.dmg"
test_cask.homepage.must_equal "http://example.com/"
@ -75,7 +75,7 @@ describe Hbc::DSL do
ENV.stub :[], stub do
shutup do
test_cask = Hbc.load("with-dsl-version")
test_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-dsl-version.rb")
test_cask.token.must_equal "with-dsl-version"
test_cask.url.to_s.must_equal "http://example.com/TestCask.dmg"
test_cask.homepage.must_equal "http://example.com/"
@ -233,7 +233,7 @@ describe Hbc::DSL do
describe "url stanza" do
it "prevents defining multiple urls" do
err = lambda {
Hbc.load("invalid/invalid-two-url")
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-two-url.rb")
}.must_raise(Hbc::CaskInvalidError)
err.message.must_include "'url' stanza may only appear once"
end
@ -242,7 +242,7 @@ describe Hbc::DSL do
describe "homepage stanza" do
it "prevents defining multiple homepages" do
err = lambda {
Hbc.load("invalid/invalid-two-homepage")
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-two-homepage.rb")
}.must_raise(Hbc::CaskInvalidError)
err.message.must_include "'homepage' stanza may only appear once"
end
@ -251,7 +251,7 @@ describe Hbc::DSL do
describe "version stanza" do
it "prevents defining multiple versions" do
err = lambda {
Hbc.load("invalid/invalid-two-version")
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-two-version.rb")
}.must_raise(Hbc::CaskInvalidError)
err.message.must_include "'version' stanza may only appear once"
end
@ -259,77 +259,77 @@ describe Hbc::DSL do
describe "appcast stanza" do
it "allows appcasts to be specified" do
cask = Hbc.load("with-appcast")
cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-appcast.rb")
cask.appcast.to_s.must_match(/^http/)
end
it "prevents defining multiple appcasts" do
err = lambda {
Hbc.load("invalid/invalid-appcast-multiple")
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-appcast-multiple.rb")
}.must_raise(Hbc::CaskInvalidError)
err.message.must_include "'appcast' stanza may only appear once"
end
it "refuses to load invalid appcast URLs" do
lambda {
Hbc.load("invalid/invalid-appcast-url")
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-appcast-url.rb")
}.must_raise(Hbc::CaskInvalidError)
end
end
describe "gpg stanza" do
it "allows gpg stanza to be specified" do
cask = Hbc.load("with-gpg")
cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-gpg.rb")
cask.gpg.to_s.must_match(/\S/)
end
it "allows gpg stanza to be specified with :key_url" do
cask = Hbc.load("with-gpg-key-url")
cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-gpg-key-url.rb")
cask.gpg.to_s.must_match(/\S/)
end
it "prevents specifying gpg stanza multiple times" do
err = lambda {
Hbc.load("invalid/invalid-gpg-multiple-stanzas")
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-gpg-multiple-stanzas.rb")
}.must_raise(Hbc::CaskInvalidError)
err.message.must_include "'gpg' stanza may only appear once"
end
it "prevents missing gpg key parameters" do
err = lambda {
Hbc.load("invalid/invalid-gpg-missing-key")
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-gpg-missing-key.rb")
}.must_raise(Hbc::CaskInvalidError)
err.message.must_include "'gpg' stanza must include exactly one"
end
it "prevents conflicting gpg key parameters" do
err = lambda {
Hbc.load("invalid/invalid-gpg-conflicting-keys")
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-gpg-conflicting-keys.rb")
}.must_raise(Hbc::CaskInvalidError)
err.message.must_include "'gpg' stanza must include exactly one"
end
it "refuses to load invalid gpg signature URLs" do
lambda {
Hbc.load("invalid/invalid-gpg-signature-url")
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-gpg-signature-url.rb")
}.must_raise(Hbc::CaskInvalidError)
end
it "refuses to load invalid gpg key URLs" do
lambda {
Hbc.load("invalid/invalid-gpg-key-url")
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-gpg-key-url.rb")
}.must_raise(Hbc::CaskInvalidError)
end
it "refuses to load invalid gpg key IDs" do
lambda {
Hbc.load("invalid/invalid-gpg-key-id")
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-gpg-key-id.rb")
}.must_raise(Hbc::CaskInvalidError)
end
it "refuses to load if gpg parameter is unknown" do
lambda {
Hbc.load("invalid/invalid-gpg-parameter")
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-gpg-parameter.rb")
}.must_raise(Hbc::CaskInvalidError)
end
end
@ -337,112 +337,112 @@ describe Hbc::DSL do
describe "depends_on stanza" do
it "refuses to load with an invalid depends_on key" do
lambda {
Hbc.load("invalid/invalid-depends-on-key")
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-depends-on-key.rb")
}.must_raise(Hbc::CaskInvalidError)
end
end
describe "depends_on formula" do
it "allows depends_on formula to be specified" do
cask = Hbc.load("with-depends-on-formula")
cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-formula.rb")
cask.depends_on.formula.wont_be_nil
end
it "allows multiple depends_on formula to be specified" do
cask = Hbc.load("with-depends-on-formula-multiple")
cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-formula-multiple.rb")
cask.depends_on.formula.wont_be_nil
end
end
describe "depends_on cask" do
it "allows depends_on cask to be specified" do
cask = Hbc.load("with-depends-on-cask")
cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask.rb")
cask.depends_on.cask.wont_be_nil
end
it "allows multiple depends_on cask to be specified" do
cask = Hbc.load("with-depends-on-cask-multiple")
cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask-multiple.rb")
cask.depends_on.cask.wont_be_nil
end
end
describe "depends_on macos" do
it "allows depends_on macos to be specified" do
cask = Hbc.load("with-depends-on-macos-string")
cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-string.rb")
cask.depends_on.macos.wont_be_nil
end
it "refuses to load with an invalid depends_on macos value" do
lambda {
Hbc.load("invalid/invalid-depends-on-macos-bad-release")
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-depends-on-macos-bad-release.rb")
}.must_raise(Hbc::CaskInvalidError)
end
it "refuses to load with conflicting depends_on macos forms" do
lambda {
Hbc.load("invalid/invalid-depends-on-macos-conflicting-forms")
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-depends-on-macos-conflicting-forms.rb")
}.must_raise(Hbc::CaskInvalidError)
end
end
describe "depends_on arch" do
it "allows depends_on arch to be specified" do
cask = Hbc.load("with-depends-on-arch")
cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-arch.rb")
cask.depends_on.arch.wont_be_nil
end
it "refuses to load with an invalid depends_on arch value" do
lambda {
Hbc.load("invalid/invalid-depends-on-arch-value")
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-depends-on-arch-value.rb")
}.must_raise(Hbc::CaskInvalidError)
end
end
describe "depends_on x11" do
it "allows depends_on x11 to be specified" do
cask = Hbc.load("with-depends-on-x11")
cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-x11.rb")
cask.depends_on.x11.wont_be_nil
end
it "refuses to load with an invalid depends_on x11 value" do
lambda {
Hbc.load("invalid/invalid-depends-on-x11-value")
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-depends-on-x11-value.rb")
}.must_raise(Hbc::CaskInvalidError)
end
end
describe "conflicts_with stanza" do
it "allows conflicts_with stanza to be specified" do
cask = Hbc.load("with-conflicts-with")
cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-conflicts-with.rb")
cask.conflicts_with.formula.wont_be_nil
end
it "refuses to load invalid conflicts_with key" do
lambda {
Hbc.load("invalid/invalid-conflicts-with-key")
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-conflicts-with-key.rb")
}.must_raise(Hbc::CaskInvalidError)
end
end
describe "installer stanza" do
it "allows installer script to be specified" do
cask = Hbc.load("with-installer-script")
cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installer-script.rb")
cask.artifacts[:installer].first.script[:executable].must_equal "/usr/bin/true"
cask.artifacts[:installer].first.script[:args].must_equal ["--flag"]
cask.artifacts[:installer].to_a[1].script[:executable].must_equal "/usr/bin/false"
cask.artifacts[:installer].to_a[1].script[:args].must_equal ["--flag"]
end
it "allows installer manual to be specified" do
cask = Hbc.load("with-installer-manual")
cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installer-manual.rb")
cask.artifacts[:installer].first.manual.must_equal "Caffeine.app"
end
end
describe "stage_only stanza" do
it "allows stage_only stanza to be specified" do
cask = Hbc.load("stage-only")
cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/stage-only.rb")
cask.artifacts[:stage_only].first.must_equal [true]
end
it "prevents specifying stage_only with other activatables" do
err = lambda {
Hbc.load("invalid/invalid-stage-only-conflict")
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/invalid/invalid-stage-only-conflict.rb")
}.must_raise(Hbc::CaskInvalidError)
err.message.must_include "'stage_only' must be the only activatable artifact"
end
@ -450,14 +450,14 @@ describe Hbc::DSL do
describe "auto_updates stanza" do
it "allows auto_updates stanza to be specified" do
cask = Hbc.load("auto-updates")
cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb")
cask.auto_updates.must_equal true
end
end
describe "appdir" do
it "allows interpolation of the appdir value in stanzas" do
cask = Hbc.load("appdir-interpolation")
cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/appdir-interpolation.rb")
cask.artifacts[:binary].first.must_equal ["#{Hbc.appdir}/some/path"]
end

View File

@ -7,7 +7,7 @@ describe Hbc::Installer do
}
it "downloads and installs a nice fresh Cask" do
caffeine = Hbc.load("local-caffeine")
caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
shutup do
Hbc::Installer.new(caffeine).install
@ -20,7 +20,7 @@ describe Hbc::Installer do
end
it "works with dmg-based Casks" do
asset = Hbc.load("container-dmg")
asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-dmg.rb")
shutup do
Hbc::Installer.new(asset).install
@ -33,7 +33,7 @@ describe Hbc::Installer do
end
it "works with tar-gz-based Casks" do
asset = Hbc.load("container-tar-gz")
asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-tar-gz.rb")
shutup do
Hbc::Installer.new(asset).install
@ -47,7 +47,7 @@ describe Hbc::Installer do
it "works with cab-based Casks" do
skip("cabextract not installed") if which("cabextract").nil?
asset = Hbc.load("container-cab")
asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-cab.rb")
asset.stub :depends_on, empty_depends_on_stub do
shutup do
@ -63,7 +63,7 @@ describe Hbc::Installer do
it "works with Adobe AIR-based Casks" do
skip("Adobe AIR not installed") unless Hbc::Container::Air.installer_exist?
asset = Hbc.load("container-air")
asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-air.rb")
shutup do
Hbc::Installer.new(asset).install
@ -77,7 +77,7 @@ describe Hbc::Installer do
it "works with 7z-based Casks" do
skip("unar not installed") if which("unar").nil?
asset = Hbc.load("container-7z")
asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-7z.rb")
asset.stub :depends_on, empty_depends_on_stub do
shutup do
@ -92,7 +92,7 @@ describe Hbc::Installer do
end
it "works with xar-based Casks" do
asset = Hbc.load("container-xar")
asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-xar.rb")
shutup do
Hbc::Installer.new(asset).install
@ -106,7 +106,7 @@ describe Hbc::Installer do
it "works with Stuffit-based Casks" do
skip("unar not installed") if which("unar").nil?
asset = Hbc.load("container-sit")
asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-sit.rb")
asset.stub :depends_on, empty_depends_on_stub do
shutup do
@ -122,7 +122,7 @@ describe Hbc::Installer do
it "works with RAR-based Casks" do
skip("unar not installed") if which("unar").nil?
asset = Hbc.load("container-rar")
asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-rar.rb")
asset.stub :depends_on, empty_depends_on_stub do
shutup do
@ -137,7 +137,7 @@ describe Hbc::Installer do
end
it "works with pure bzip2-based Casks" do
asset = Hbc.load("container-bzip2")
asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-bzip2.rb")
shutup do
Hbc::Installer.new(asset).install
@ -150,7 +150,7 @@ describe Hbc::Installer do
end
it "works with pure gzip-based Casks" do
asset = Hbc.load("container-gzip")
asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-gzip.rb")
shutup do
Hbc::Installer.new(asset).install
@ -164,7 +164,7 @@ describe Hbc::Installer do
it "works with pure xz-based Casks" do
skip("unxz not installed") if which("unxz").nil?
asset = Hbc.load("container-xz")
asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-xz.rb")
asset.stub :depends_on, empty_depends_on_stub do
shutup do
@ -180,7 +180,7 @@ describe Hbc::Installer do
it "works with lzma-based Casks" do
skip("unlzma not installed") if which("unlzma").nil?
asset = Hbc.load("container-lzma")
asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-lzma.rb")
asset.stub :depends_on, empty_depends_on_stub do
shutup do
@ -195,7 +195,7 @@ describe Hbc::Installer do
end
it "blows up on a bad checksum" do
bad_checksum = Hbc.load("bad-checksum")
bad_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/bad-checksum.rb")
lambda {
shutup do
Hbc::Installer.new(bad_checksum).install
@ -204,7 +204,7 @@ describe Hbc::Installer do
end
it "blows up on a missing checksum" do
missing_checksum = Hbc.load("missing-checksum")
missing_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/missing-checksum.rb")
lambda {
shutup do
Hbc::Installer.new(missing_checksum).install
@ -213,7 +213,7 @@ describe Hbc::Installer do
end
it "installs fine if sha256 :no_check is used" do
no_checksum = Hbc.load("no-checksum")
no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb")
shutup do
Hbc::Installer.new(no_checksum).install
@ -223,14 +223,14 @@ describe Hbc::Installer do
end
it "fails to install if sha256 :no_check is used with --require-sha" do
no_checksum = Hbc.load("no-checksum")
no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb")
lambda {
Hbc::Installer.new(no_checksum, require_sha: true).install
}.must_raise(Hbc::CaskNoShasumError)
end
it "installs fine if sha256 :no_check is used with --require-sha and --force" do
no_checksum = Hbc.load("no-checksum")
no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb")
shutup do
Hbc::Installer.new(no_checksum, require_sha: true, force: true).install
@ -240,7 +240,7 @@ describe Hbc::Installer do
end
it "prints caveats if they're present" do
with_caveats = Hbc.load("with-caveats")
with_caveats = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-caveats.rb")
lambda {
Hbc::Installer.new(with_caveats).install
}.must_output(/Here are some things you might want to know/)
@ -248,7 +248,7 @@ describe Hbc::Installer do
end
it "prints installer :manual instructions when present" do
with_installer_manual = Hbc.load("with-installer-manual")
with_installer_manual = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installer-manual.rb")
lambda {
Hbc::Installer.new(with_installer_manual).install
}.must_output(/To complete the installation of Cask with-installer-manual, you must also\nrun the installer at\n\n '#{with_installer_manual.staged_path.join('Caffeine.app')}'/)
@ -256,7 +256,7 @@ describe Hbc::Installer do
end
it "does not extract __MACOSX directories from zips" do
with_macosx_dir = Hbc.load("with-macosx-dir")
with_macosx_dir = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-macosx-dir.rb")
shutup do
Hbc::Installer.new(with_macosx_dir).install
@ -266,7 +266,7 @@ describe Hbc::Installer do
end
it "installer method raises an exception when already-installed Casks which auto-update are attempted" do
auto_updates = Hbc.load("auto-updates")
auto_updates = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb")
auto_updates.installed?.must_equal false
installer = Hbc::Installer.new(auto_updates)
@ -280,7 +280,7 @@ describe Hbc::Installer do
end
it "allows already-installed Casks which auto-update to be installed if force is provided" do
auto_updates = Hbc.load("auto-updates")
auto_updates = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb")
auto_updates.installed?.must_equal false
shutup do
@ -294,7 +294,7 @@ describe Hbc::Installer do
# unlike the CLI, the internal interface throws exception on double-install
it "installer method raises an exception when already-installed Casks are attempted" do
transmission = Hbc.load("local-transmission")
transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")
transmission.installed?.must_equal false
installer = Hbc::Installer.new(transmission)
@ -308,7 +308,7 @@ describe Hbc::Installer do
end
it "allows already-installed Casks to be installed if force is provided" do
transmission = Hbc.load("local-transmission")
transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")
transmission.installed?.must_equal false
shutup do
@ -321,7 +321,7 @@ describe Hbc::Installer do
end
it "works naked-pkg-based Casks" do
naked_pkg = Hbc.load("container-pkg")
naked_pkg = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-pkg.rb")
shutup do
Hbc::Installer.new(naked_pkg).install
@ -333,7 +333,7 @@ describe Hbc::Installer do
end
it "works properly with an overridden container :type" do
naked_executable = Hbc.load("naked-executable")
naked_executable = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/naked-executable.rb")
shutup do
Hbc::Installer.new(naked_executable).install
@ -345,7 +345,7 @@ describe Hbc::Installer do
end
it "works fine with a nested container" do
nested_app = Hbc.load("nested-app")
nested_app = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/nested-app.rb")
shutup do
Hbc::Installer.new(nested_app).install
@ -356,7 +356,7 @@ describe Hbc::Installer do
end
it "generates and finds a timestamped metadata directory for an installed Cask" do
caffeine = Hbc.load("local-caffeine")
caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
shutup do
Hbc::Installer.new(caffeine).install
@ -368,7 +368,7 @@ describe Hbc::Installer do
end
it "generates and finds a metadata subdirectory for an installed Cask" do
caffeine = Hbc.load("local-caffeine")
caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
shutup do
Hbc::Installer.new(caffeine).install
@ -383,7 +383,7 @@ describe Hbc::Installer do
describe "uninstall" do
it "fully uninstalls a Cask" do
caffeine = Hbc.load("local-caffeine")
caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
installer = Hbc::Installer.new(caffeine)
shutup do
@ -397,7 +397,7 @@ describe Hbc::Installer do
end
it "uninstalls all versions if force is set" do
caffeine = Hbc.load("local-caffeine")
caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")
mutated_version = caffeine.version + ".1"
shutup do

View File

@ -6,7 +6,7 @@ require "test_helper"
describe "Operations on staged Casks" do
describe "bundle ID" do
it "fetches the bundle ID from a staged cask" do
transmission_cask = Hbc.load("local-transmission")
transmission_cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")
tr_installer = Hbc::Installer.new(transmission_cask)
shutup do

View File

@ -2,7 +2,7 @@ require "test_helper"
describe Hbc::UrlChecker do
describe "request processing" do
let(:cask) { Hbc.load("basic-cask") }
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") }
let(:checker) { Hbc::UrlChecker.new(cask) }
let(:with_stubbed_fetcher) {
lambda { |&block|

View File

@ -41,8 +41,8 @@ describe "Cask" do
end
it "uses exact match when loading by token" do
Hbc.load("test-opera").token.must_equal("test-opera")
Hbc.load("test-opera-mail").token.must_equal("test-opera-mail")
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/test-opera.rb").token.must_equal("test-opera")
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/test-opera-mail.rb").token.must_equal("test-opera-mail")
end
it "raises an error when attempting to load a Cask that doesn't exist" do

View File

@ -46,7 +46,7 @@ Hbc.caskroom = Hbc.default_caskroom.tap(&:mkpath)
Hbc.default_tap = Tap.fetch("caskroom", "test").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
# pretend that the caskroom/cask Tap is installed

Some files were not shown because too many files have changed in this diff Show More