diff options
| author | Markus Reiter | 2017-10-07 15:58:49 +0200 |
|---|---|---|
| committer | Markus Reiter | 2017-10-07 16:11:25 +0200 |
| commit | 97333df4cb4bd006401193639400a8bc6df56e3a (patch) | |
| tree | d04a2c243da0486c4e3248e74f392c6716c8bf88 | |
| parent | 113e5da55e630018cba9da19f4d3b268c2e7ee37 (diff) | |
| download | brew-97333df4cb4bd006401193639400a8bc6df56e3a.tar.bz2 | |
Add helper method for Cask fixture paths and refactor CaskLoader.
37 files changed, 115 insertions, 112 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/audit.rb b/Library/Homebrew/cask/lib/hbc/audit.rb index 9ab93a67f..c15fa6307 100644 --- a/Library/Homebrew/cask/lib/hbc/audit.rb +++ b/Library/Homebrew/cask/lib/hbc/audit.rb @@ -71,7 +71,7 @@ module Hbc return if previous_cask_contents.empty? begin - previous_cask = CaskLoader.load_from_string(previous_cask_contents) + previous_cask = CaskLoader.load(previous_cask_contents) return unless previous_cask.version == cask.version return if previous_cask.sha256 == cask.sha256 diff --git a/Library/Homebrew/cask/lib/hbc/auditor.rb b/Library/Homebrew/cask/lib/hbc/auditor.rb index 48f36a54d..231c005f9 100644 --- a/Library/Homebrew/cask/lib/hbc/auditor.rb +++ b/Library/Homebrew/cask/lib/hbc/auditor.rb @@ -43,7 +43,7 @@ module Hbc def audit_languages(languages) ohai "Auditing language: #{languages.map { |lang| "'#{lang}'" }.join(", ")}" MacOS.instance_variable_set(:@languages, languages) - audit_cask_instance(CaskLoader.load_from_file(cask.sourcefile_path)) + audit_cask_instance(CaskLoader.load(cask.sourcefile_path)) ensure CLI::Cleanup.run(cask.token) if audit_download? end diff --git a/Library/Homebrew/cask/lib/hbc/cask_loader.rb b/Library/Homebrew/cask/lib/hbc/cask_loader.rb index 8fce9636a..5660992da 100644 --- a/Library/Homebrew/cask/lib/hbc/cask_loader.rb +++ b/Library/Homebrew/cask/lib/hbc/cask_loader.rb @@ -147,14 +147,6 @@ module Hbc end end - def self.load_from_file(path) - FromPathLoader.new(path).load - end - - def self.load_from_string(content) - FromContentLoader.new(content).load - end - def self.path(ref) self.for(ref).path end @@ -164,6 +156,13 @@ module Hbc end def self.for(ref) + if ref.respond_to?(:to_str) + content = ref.to_str + if content.match?(/\A\s*cask\s+(?:"[^"]*"|'[^']*')\s+do(?:\s+.*\s+|;?\s+)end\s*\Z/) + return FromContentLoader.new(content) + end + end + [ FromInstanceLoader, FromURILoader, diff --git a/Library/Homebrew/cask/lib/hbc/cli/list.rb b/Library/Homebrew/cask/lib/hbc/cli/list.rb index 32415af8a..72b78d110 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/list.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/list.rb @@ -23,7 +23,7 @@ module Hbc elsif versions? puts self.class.format_versioned(cask) else - cask = CaskLoader.load_from_file(cask.installed_caskfile) + cask = CaskLoader.load(cask.installed_caskfile) self.class.list_artifacts(cask) end end diff --git a/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb b/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb index 7e55db5f1..f2059605c 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb @@ -16,7 +16,7 @@ module Hbc if cask.installed? && !cask.installed_caskfile.nil? # use the same cask file that was used for installation, if possible - cask = CaskLoader.load_from_file(cask.installed_caskfile) if cask.installed_caskfile.exist? + cask = CaskLoader.load(cask.installed_caskfile) if cask.installed_caskfile.exist? end Installer.new(cask, binaries: binaries?, verbose: verbose?, force: force?).uninstall diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb index 01aae935d..ee4494a62 100644 --- a/Library/Homebrew/cask/lib/hbc/installer.rb +++ b/Library/Homebrew/cask/lib/hbc/installer.rb @@ -126,7 +126,7 @@ module Hbc # use the same cask file that was used for installation, if possible installed_caskfile = @cask.installed_caskfile - installed_cask = installed_caskfile.exist? ? CaskLoader.load_from_file(installed_caskfile) : @cask + installed_cask = installed_caskfile.exist? ? CaskLoader.load(installed_caskfile) : @cask # Always force uninstallation, ignore method parameter Installer.new(installed_cask, binaries: binaries?, verbose: verbose?, force: true).uninstall diff --git a/Library/Homebrew/test/cask/accessibility_spec.rb b/Library/Homebrew/test/cask/accessibility_spec.rb index 9e56f6bd3..b77bcb002 100644 --- a/Library/Homebrew/test/cask/accessibility_spec.rb +++ b/Library/Homebrew/test/cask/accessibility_spec.rb @@ -1,7 +1,7 @@ # TODO: this test should be named after the corresponding class, once # that class is abstracted from installer.rb. describe "Accessibility Access", :cask do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-accessibility-access.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-accessibility-access")) } let(:fake_system_command) { class_double(Hbc::SystemCommand) } let(:installer) { Hbc::Installer.new(cask, command: fake_system_command) } diff --git a/Library/Homebrew/test/cask/artifact/alt_target_spec.rb b/Library/Homebrew/test/cask/artifact/alt_target_spec.rb index 02be796ed..346b90e78 100644 --- a/Library/Homebrew/test/cask/artifact/alt_target_spec.rb +++ b/Library/Homebrew/test/cask/artifact/alt_target_spec.rb @@ -1,6 +1,6 @@ describe Hbc::Artifact::App, :cask do describe "activate to alternate target" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-alt-target.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-alt-target")) } let(:install_phase) { -> { described_class.for_cask(cask).each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } } diff --git a/Library/Homebrew/test/cask/artifact/app_spec.rb b/Library/Homebrew/test/cask/artifact/app_spec.rb index f67ffd31b..b38a60317 100644 --- a/Library/Homebrew/test/cask/artifact/app_spec.rb +++ b/Library/Homebrew/test/cask/artifact/app_spec.rb @@ -1,5 +1,5 @@ describe Hbc::Artifact::App, :cask do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("local-caffeine")) } let(:command) { Hbc::SystemCommand } let(:force) { false } let(:app) { described_class.for_cask(cask).first } diff --git a/Library/Homebrew/test/cask/artifact/binary_spec.rb b/Library/Homebrew/test/cask/artifact/binary_spec.rb index 5ffaca861..bbd125864 100644 --- a/Library/Homebrew/test/cask/artifact/binary_spec.rb +++ b/Library/Homebrew/test/cask/artifact/binary_spec.rb @@ -1,6 +1,6 @@ describe Hbc::Artifact::Binary, :cask do let(:cask) { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-binary.rb").tap do |cask| + Hbc::CaskLoader.load(cask_path("with-binary")).tap do |cask| InstallHelper.install_without_artifacts(cask) end } @@ -16,7 +16,7 @@ describe Hbc::Artifact::Binary, :cask do context "when --no-binaries is specified" do let(:cask) { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-binary.rb") + Hbc::CaskLoader.load(cask_path("with-binary")) } it "doesn't link the binary when --no-binaries is specified" do @@ -35,7 +35,7 @@ describe Hbc::Artifact::Binary, :cask do context "when the binary is not executable" do let(:cask) { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-non-executable-binary.rb").tap do |cask| + Hbc::CaskLoader.load(cask_path("with-non-executable-binary")).tap do |cask| InstallHelper.install_without_artifacts(cask) end } @@ -85,7 +85,7 @@ describe Hbc::Artifact::Binary, :cask do context "binary is inside an app package" do let(:cask) { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-embedded-binary.rb").tap do |cask| + Hbc::CaskLoader.load(cask_path("with-embedded-binary")).tap do |cask| InstallHelper.install_without_artifacts(cask) end } diff --git a/Library/Homebrew/test/cask/artifact/generic_artifact_spec.rb b/Library/Homebrew/test/cask/artifact/generic_artifact_spec.rb index bec8c2742..bcd3155d3 100644 --- a/Library/Homebrew/test/cask/artifact/generic_artifact_spec.rb +++ b/Library/Homebrew/test/cask/artifact/generic_artifact_spec.rb @@ -1,5 +1,5 @@ describe Hbc::Artifact::Artifact, :cask do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-generic-artifact.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-generic-artifact")) } let(:install_phase) { -> { described_class.for_cask(cask).each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } } @@ -15,7 +15,7 @@ describe Hbc::Artifact::Artifact, :cask do context "without target" do it "fails to load" do expect { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-generic-artifact-no-target.rb") + Hbc::CaskLoader.load(cask_path("with-generic-artifact-no-target")) }.to raise_error(Hbc::CaskInvalidError, /target required for Generic Artifact/) end end diff --git a/Library/Homebrew/test/cask/artifact/nested_container_spec.rb b/Library/Homebrew/test/cask/artifact/nested_container_spec.rb index 41d143764..ef23c3fd7 100644 --- a/Library/Homebrew/test/cask/artifact/nested_container_spec.rb +++ b/Library/Homebrew/test/cask/artifact/nested_container_spec.rb @@ -1,7 +1,7 @@ describe Hbc::Artifact::NestedContainer, :cask do describe "install" do it "extracts the specified paths as containers" do - cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/nested-app.rb").tap do |c| + cask = Hbc::CaskLoader.load(cask_path("nested-app")).tap do |c| InstallHelper.install_without_artifacts(c) end diff --git a/Library/Homebrew/test/cask/artifact/pkg_spec.rb b/Library/Homebrew/test/cask/artifact/pkg_spec.rb index c6a45c49a..71eb7bf4f 100644 --- a/Library/Homebrew/test/cask/artifact/pkg_spec.rb +++ b/Library/Homebrew/test/cask/artifact/pkg_spec.rb @@ -1,5 +1,5 @@ describe Hbc::Artifact::Pkg, :cask do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-installable")) } let(:fake_system_command) { class_double(Hbc::SystemCommand) } before(:each) do @@ -22,7 +22,7 @@ describe Hbc::Artifact::Pkg, :cask do end describe "choices" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-choices.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-choices")) } it "passes the choice changes xml to the system installer" do pkg = described_class.for_cask(cask).first diff --git a/Library/Homebrew/test/cask/artifact/suite_spec.rb b/Library/Homebrew/test/cask/artifact/suite_spec.rb index 2f913fecc..5c322e0e2 100644 --- a/Library/Homebrew/test/cask/artifact/suite_spec.rb +++ b/Library/Homebrew/test/cask/artifact/suite_spec.rb @@ -1,5 +1,5 @@ describe Hbc::Artifact::Suite, :cask do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-suite.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-suite")) } let(:install_phase) { -> { described_class.for_cask(cask).each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } } diff --git a/Library/Homebrew/test/cask/artifact/two_apps_correct_spec.rb b/Library/Homebrew/test/cask/artifact/two_apps_correct_spec.rb index f6e0d3c97..536296620 100644 --- a/Library/Homebrew/test/cask/artifact/two_apps_correct_spec.rb +++ b/Library/Homebrew/test/cask/artifact/two_apps_correct_spec.rb @@ -1,6 +1,6 @@ describe Hbc::Artifact::App, :cask do describe "multiple apps" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-two-apps-correct.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-two-apps-correct")) } let(:install_phase) { -> { described_class.for_cask(cask).each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } } @@ -27,7 +27,7 @@ describe Hbc::Artifact::App, :cask do end describe "when apps are in a subdirectory" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-two-apps-subdir.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-two-apps-subdir")) } it "installs both apps using the proper target directory" do install_phase.call diff --git a/Library/Homebrew/test/cask/artifact/two_apps_incorrect_spec.rb b/Library/Homebrew/test/cask/artifact/two_apps_incorrect_spec.rb index 6427ec32c..cda5b4488 100644 --- a/Library/Homebrew/test/cask/artifact/two_apps_incorrect_spec.rb +++ b/Library/Homebrew/test/cask/artifact/two_apps_incorrect_spec.rb @@ -2,7 +2,7 @@ describe Hbc::Artifact::App, :cask do # 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") + # Hbc::CaskLoader.load(cask_path("with-two-apps-incorrect")) # }.must_raise # # TODO: later give the user a nice exception for this case and check for it here # end diff --git a/Library/Homebrew/test/cask/artifact/uninstall_no_zap_spec.rb b/Library/Homebrew/test/cask/artifact/uninstall_no_zap_spec.rb index d6a8393da..f1940fc4d 100644 --- a/Library/Homebrew/test/cask/artifact/uninstall_no_zap_spec.rb +++ b/Library/Homebrew/test/cask/artifact/uninstall_no_zap_spec.rb @@ -1,5 +1,5 @@ describe Hbc::Artifact::Zap, :cask do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-installable")) } let(:zap_artifact) { described_class.for_cask(cask).first diff --git a/Library/Homebrew/test/cask/artifact/uninstall_zap_shared_examples.rb b/Library/Homebrew/test/cask/artifact/uninstall_zap_shared_examples.rb index 4fdab60d0..59f3d946f 100644 --- a/Library/Homebrew/test/cask/artifact/uninstall_zap_shared_examples.rb +++ b/Library/Homebrew/test/cask/artifact/uninstall_zap_shared_examples.rb @@ -6,7 +6,7 @@ shared_examples "#uninstall_phase or #zap_phase" do subject { artifact.public_send(:"#{artifact_dsl_key}_phase", command: fake_system_command) } context "using :launchctl" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-#{artifact_dsl_key}-launchctl.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-launchctl")) } 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" } @@ -61,7 +61,7 @@ shared_examples "#uninstall_phase or #zap_phase" do context "using :pkgutil" do let(:fake_system_command) { class_double(Hbc::SystemCommand) } - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-#{artifact_dsl_key}-pkgutil.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-pkgutil")) } let(:main_pkg_id) { "my.fancy.package.main" } let(:agent_pkg_id) { "my.fancy.package.agent" } @@ -85,7 +85,7 @@ shared_examples "#uninstall_phase or #zap_phase" do end context "using :kext" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-#{artifact_dsl_key}-kext.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-kext")) } let(:kext_id) { "my.fancy.package.kernelextension" } it "is supported" do @@ -110,7 +110,7 @@ shared_examples "#uninstall_phase or #zap_phase" do end context "using :quit" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-#{artifact_dsl_key}-quit.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-quit")) } let(:bundle_id) { "my.fancy.package.app" } let(:quit_application_script) do %Q(tell application id "#{bundle_id}" to quit) @@ -130,7 +130,7 @@ shared_examples "#uninstall_phase or #zap_phase" do end context "using :signal" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-#{artifact_dsl_key}-signal.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-signal")) } let(:bundle_id) { "my.fancy.package.app" } let(:signals) { %w[TERM KILL] } let(:unix_pids) { [12_345, 67_890] } @@ -172,7 +172,7 @@ shared_examples "#uninstall_phase or #zap_phase" do end let(:fake_system_command) { Hbc::NeverSudoSystemCommand } - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-#{artifact_dsl_key}-#{directive}.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-#{directive}")) } before(:each) do allow_any_instance_of(Hbc::Artifact::AbstractUninstall).to receive(:trash_paths) @@ -198,7 +198,7 @@ shared_examples "#uninstall_phase or #zap_phase" do context "using :rmdir" do let(:fake_system_command) { Hbc::NeverSudoSystemCommand } - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-#{artifact_dsl_key}-rmdir.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-rmdir")) } let(:empty_directory) { Pathname.new("#{TEST_TMPDIR}/empty_directory_path") } let(:ds_store) { empty_directory.join(".DS_Store") } @@ -226,7 +226,7 @@ shared_examples "#uninstall_phase or #zap_phase" do context "using #{script_type.inspect}" do let(:fake_system_command) { Hbc::NeverSudoSystemCommand } let(:token) { "with-#{artifact_dsl_key}-#{script_type}".tr("_", "-") } - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/#{token}.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path(token.to_s)) } let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") } it "is supported" do @@ -252,7 +252,7 @@ shared_examples "#uninstall_phase or #zap_phase" do end context "using :login_item" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-#{artifact_dsl_key}-login-item.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-login-item")) } it "is supported" do Hbc::FakeSystemCommand.expects_command( diff --git a/Library/Homebrew/test/cask/cli/fetch_spec.rb b/Library/Homebrew/test/cask/cli/fetch_spec.rb index 087a30f50..67cf6e61d 100644 --- a/Library/Homebrew/test/cask/cli/fetch_spec.rb +++ b/Library/Homebrew/test/cask/cli/fetch_spec.rb @@ -3,11 +3,11 @@ require_relative "shared_examples/invalid_option" describe Hbc::CLI::Fetch, :cask do let(:local_transmission) { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") + Hbc::CaskLoader.load(cask_path("local-transmission")) } let(:local_caffeine) { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") + Hbc::CaskLoader.load(cask_path("local-caffeine")) } it_behaves_like "a command that requires a Cask token" diff --git a/Library/Homebrew/test/cask/cli/install_spec.rb b/Library/Homebrew/test/cask/cli/install_spec.rb index 17a7b9f99..c918a3529 100644 --- a/Library/Homebrew/test/cask/cli/install_spec.rb +++ b/Library/Homebrew/test/cask/cli/install_spec.rb @@ -22,16 +22,16 @@ describe Hbc::CLI::Install, :cask do it "allows staging and activation of multiple Casks at once" do described_class.run("local-transmission", "local-caffeine") - expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed + expect(Hbc::CaskLoader.load(cask_path("local-transmission"))).to be_installed expect(Hbc.appdir.join("Transmission.app")).to be_a_directory - expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")).to be_installed + expect(Hbc::CaskLoader.load(cask_path("local-caffeine"))).to be_installed expect(Hbc.appdir.join("Caffeine.app")).to be_a_directory end it "skips double install (without nuking existing installation)" do described_class.run("local-transmission") described_class.run("local-transmission") - expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed + expect(Hbc::CaskLoader.load(cask_path("local-transmission"))).to be_installed end it "prints a warning message on double install" do @@ -54,9 +54,9 @@ describe Hbc::CLI::Install, :cask do it "skips dependencies with --skip-cask-deps" do described_class.run("with-depends-on-cask-multiple", "--skip-cask-deps") - expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask-multiple.rb")).to be_installed - expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb")).not_to be_installed - expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).not_to be_installed + expect(Hbc::CaskLoader.load(cask_path("with-depends-on-cask-multiple"))).to be_installed + expect(Hbc::CaskLoader.load(cask_path("local-caffeine"))).not_to be_installed + expect(Hbc::CaskLoader.load(cask_path("local-transmission"))).not_to be_installed end it "properly handles Casks that are not present" do diff --git a/Library/Homebrew/test/cask/cli/list_spec.rb b/Library/Homebrew/test/cask/cli/list_spec.rb index 75da82762..58d8bc632 100644 --- a/Library/Homebrew/test/cask/cli/list_spec.rb +++ b/Library/Homebrew/test/cask/cli/list_spec.rb @@ -65,8 +65,8 @@ describe Hbc::CLI::List, :cask do end describe "given a set of installed Casks" do - 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(:caffeine) { Hbc::CaskLoader.load(cask_path("local-caffeine")) } + let(:transmission) { Hbc::CaskLoader.load(cask_path("local-transmission")) } let(:casks) { [caffeine, transmission] } it "lists the installed files for those Casks" do diff --git a/Library/Homebrew/test/cask/cli/outdated_spec.rb b/Library/Homebrew/test/cask/cli/outdated_spec.rb index 7fca8c248..5bbf18d21 100644 --- a/Library/Homebrew/test/cask/cli/outdated_spec.rb +++ b/Library/Homebrew/test/cask/cli/outdated_spec.rb @@ -3,11 +3,11 @@ require_relative "shared_examples/invalid_option" describe Hbc::CLI::Outdated, :cask do let(:installed) do [ - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb"), - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/outdated/local-caffeine.rb"), - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/outdated/local-transmission.rb"), - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/version-latest-string.rb"), - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/outdated/auto-updates.rb"), + Hbc::CaskLoader.load(cask_path("basic-cask")), + Hbc::CaskLoader.load(cask_path("outdated/local-caffeine")), + Hbc::CaskLoader.load(cask_path("outdated/local-transmission")), + Hbc::CaskLoader.load(cask_path("version-latest-string")), + Hbc::CaskLoader.load(cask_path("outdated/auto-updates")), ] end @@ -74,7 +74,7 @@ describe Hbc::CLI::Outdated, :cask do end it 'does not include the Casks with "auto_updates true" when the version did not change' do - cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb") + cask = Hbc::CaskLoader.load(cask_path("auto-updates")) InstallHelper.install_with_caskfile(cask) expect { diff --git a/Library/Homebrew/test/cask/cli/reinstall_spec.rb b/Library/Homebrew/test/cask/cli/reinstall_spec.rb index 073fbb23c..95294b695 100644 --- a/Library/Homebrew/test/cask/cli/reinstall_spec.rb +++ b/Library/Homebrew/test/cask/cli/reinstall_spec.rb @@ -4,7 +4,7 @@ describe Hbc::CLI::Reinstall, :cask do it_behaves_like "a command that handles invalid options" it "displays the reinstallation progress" do - caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") + caffeine = Hbc::CaskLoader.load(cask_path("local-caffeine")) Hbc::Installer.new(caffeine).install @@ -27,16 +27,16 @@ describe Hbc::CLI::Reinstall, :cask do it "allows reinstalling a Cask" do Hbc::CLI::Install.run("local-transmission") - expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed + expect(Hbc::CaskLoader.load(cask_path("local-transmission"))).to be_installed Hbc::CLI::Reinstall.run("local-transmission") - expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed + expect(Hbc::CaskLoader.load(cask_path("local-transmission"))).to be_installed end it "allows reinstalling a non installed Cask" do - expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).not_to be_installed + expect(Hbc::CaskLoader.load(cask_path("local-transmission"))).not_to be_installed Hbc::CLI::Reinstall.run("local-transmission") - expect(Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")).to be_installed + expect(Hbc::CaskLoader.load(cask_path("local-transmission"))).to be_installed end end diff --git a/Library/Homebrew/test/cask/cli/uninstall_spec.rb b/Library/Homebrew/test/cask/cli/uninstall_spec.rb index 9ebd80dfb..80b7edbd3 100644 --- a/Library/Homebrew/test/cask/cli/uninstall_spec.rb +++ b/Library/Homebrew/test/cask/cli/uninstall_spec.rb @@ -6,7 +6,7 @@ describe Hbc::CLI::Uninstall, :cask do it_behaves_like "a command that handles invalid options" it "displays the uninstallation progress" do - caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") + caffeine = Hbc::CaskLoader.load(cask_path("local-caffeine")) Hbc::Installer.new(caffeine).install @@ -37,8 +37,8 @@ describe Hbc::CLI::Uninstall, :cask do end it "can uninstall and unlink multiple Casks at once" do - 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") + caffeine = Hbc::CaskLoader.load(cask_path("local-caffeine")) + transmission = Hbc::CaskLoader.load(cask_path("local-transmission")) Hbc::Installer.new(caffeine).install Hbc::Installer.new(transmission).install @@ -55,7 +55,7 @@ describe Hbc::CLI::Uninstall, :cask do end it "calls `uninstall` before removing artifacts" do - cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-script-app.rb") + cask = Hbc::CaskLoader.load(cask_path("with-uninstall-script-app")) Hbc::Installer.new(cask).install @@ -71,7 +71,7 @@ describe Hbc::CLI::Uninstall, :cask do end it "can uninstall Casks when the uninstall script is missing, but only when using `--force`" do - cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-script-app.rb") + cask = Hbc::CaskLoader.load(cask_path("with-uninstall-script-app")) Hbc::Installer.new(cask).install diff --git a/Library/Homebrew/test/cask/cli/zap_spec.rb b/Library/Homebrew/test/cask/cli/zap_spec.rb index 19e8ff261..05c882854 100644 --- a/Library/Homebrew/test/cask/cli/zap_spec.rb +++ b/Library/Homebrew/test/cask/cli/zap_spec.rb @@ -11,8 +11,8 @@ describe Hbc::CLI::Zap, :cask do end it "can zap and unlink multiple Casks at once" do - 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") + caffeine = Hbc::CaskLoader.load(cask_path("local-caffeine")) + transmission = Hbc::CaskLoader.load(cask_path("local-transmission")) Hbc::Installer.new(caffeine).install Hbc::Installer.new(transmission).install diff --git a/Library/Homebrew/test/cask/conflicts_with_spec.rb b/Library/Homebrew/test/cask/conflicts_with_spec.rb index 00dc252fe..81c22ded6 100644 --- a/Library/Homebrew/test/cask/conflicts_with_spec.rb +++ b/Library/Homebrew/test/cask/conflicts_with_spec.rb @@ -1,11 +1,11 @@ describe "conflicts_with", :cask do describe "conflicts_with cask" do let(:local_caffeine) { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") + Hbc::CaskLoader.load(cask_path("local-caffeine")) } let(:with_conflicts_with) { - Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-conflicts-with.rb") + Hbc::CaskLoader.load(cask_path("with-conflicts-with")) } it "installs the dependency of a Cask and the Cask itself" do diff --git a/Library/Homebrew/test/cask/container/dmg_spec.rb b/Library/Homebrew/test/cask/container/dmg_spec.rb index 4f3f57071..df99a6264 100644 --- a/Library/Homebrew/test/cask/container/dmg_spec.rb +++ b/Library/Homebrew/test/cask/container/dmg_spec.rb @@ -1,7 +1,7 @@ describe Hbc::Container::Dmg, :cask do describe "#mount!" do it "does not store nil mounts for dmgs with extra data" do - transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") + transmission = Hbc::CaskLoader.load(cask_path("local-transmission")) dmg = Hbc::Container::Dmg.new( transmission, diff --git a/Library/Homebrew/test/cask/depends_on_spec.rb b/Library/Homebrew/test/cask/depends_on_spec.rb index 2818ff8b0..453a761f7 100644 --- a/Library/Homebrew/test/cask/depends_on_spec.rb +++ b/Library/Homebrew/test/cask/depends_on_spec.rb @@ -9,7 +9,7 @@ describe "Satisfy Dependencies and Requirements", :cask do describe "depends_on cask" do context "when depends_on cask is cyclic" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask-cyclic.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-depends-on-cask-cyclic")) } it { is_expected.to raise_error(Hbc::CaskCyclicDependencyError, "Cask 'with-depends-on-cask-cyclic' includes cyclic dependencies on other Casks: with-depends-on-cask-cyclic-helper") @@ -17,7 +17,7 @@ describe "Satisfy Dependencies and Requirements", :cask do end context do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-cask.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-depends-on-cask")) } let(:dependency) { Hbc::CaskLoader.load(cask.depends_on.cask.first) } it "installs the dependency of a Cask and the Cask itself" do @@ -30,34 +30,34 @@ describe "Satisfy Dependencies and Requirements", :cask do describe "depends_on macos" do context "given an array" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-array.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-depends-on-macos-array")) } it { is_expected.not_to raise_error } end context "given a comparison" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-comparison.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-depends-on-macos-comparison")) } it { is_expected.not_to raise_error } end context "given a string" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-string.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-depends-on-macos-string")) } it { is_expected.not_to raise_error } end context "given a symbol" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-symbol.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-depends-on-macos-symbol")) } it { is_expected.not_to raise_error } end context "when not satisfied" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-macos-failure.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-depends-on-macos-failure")) } it { is_expected.to raise_error(Hbc::CaskError) } end end describe "depends_on arch" do context "when satisfied" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-arch.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-depends-on-arch")) } it { is_expected.not_to raise_error } end end @@ -68,21 +68,21 @@ describe "Satisfy Dependencies and Requirements", :cask do end context "when satisfied" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-x11.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-depends-on-x11")) } let(:x11_installed) { true } it { is_expected.not_to raise_error } end context "when not satisfied" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-x11.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-depends-on-x11")) } let(:x11_installed) { false } it { is_expected.to raise_error(Hbc::CaskX11DependencyError) } end context "when depends_on x11: false" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-depends-on-x11-false.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("with-depends-on-x11-false")) } let(:x11_installed) { false } it { is_expected.not_to raise_error } diff --git a/Library/Homebrew/test/cask/dsl/caveats_spec.rb b/Library/Homebrew/test/cask/dsl/caveats_spec.rb index aa662e4d0..1b82d9821 100644 --- a/Library/Homebrew/test/cask/dsl/caveats_spec.rb +++ b/Library/Homebrew/test/cask/dsl/caveats_spec.rb @@ -1,7 +1,7 @@ require "test/support/helper/spec/shared_examples/hbc_dsl_base" describe Hbc::DSL::Caveats, :cask do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("basic-cask")) } let(:dsl) { Hbc::DSL::Caveats.new(cask) } it_behaves_like Hbc::DSL::Base diff --git a/Library/Homebrew/test/cask/dsl/postflight_spec.rb b/Library/Homebrew/test/cask/dsl/postflight_spec.rb index d2b080ca3..4ac3ae7cf 100644 --- a/Library/Homebrew/test/cask/dsl/postflight_spec.rb +++ b/Library/Homebrew/test/cask/dsl/postflight_spec.rb @@ -2,7 +2,7 @@ require "test/support/helper/spec/shared_examples/hbc_dsl_base" require "test/support/helper/spec/shared_examples/hbc_staged" describe Hbc::DSL::Postflight, :cask do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("basic-cask")) } let(:dsl) { Hbc::DSL::Postflight.new(cask, Hbc::FakeSystemCommand) } it_behaves_like Hbc::DSL::Base diff --git a/Library/Homebrew/test/cask/dsl/preflight_spec.rb b/Library/Homebrew/test/cask/dsl/preflight_spec.rb index b93be95ff..f78944c50 100644 --- a/Library/Homebrew/test/cask/dsl/preflight_spec.rb +++ b/Library/Homebrew/test/cask/dsl/preflight_spec.rb @@ -2,7 +2,7 @@ require "test/support/helper/spec/shared_examples/hbc_dsl_base" require "test/support/helper/spec/shared_examples/hbc_staged" describe Hbc::DSL::Preflight, :cask do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("basic-cask")) } let(:dsl) { Hbc::DSL::Preflight.new(cask, Hbc::FakeSystemCommand) } it_behaves_like Hbc::DSL::Base diff --git a/Library/Homebrew/test/cask/dsl/uninstall_postflight_spec.rb b/Library/Homebrew/test/cask/dsl/uninstall_postflight_spec.rb index f89a181ce..b2af700db 100644 --- a/Library/Homebrew/test/cask/dsl/uninstall_postflight_spec.rb +++ b/Library/Homebrew/test/cask/dsl/uninstall_postflight_spec.rb @@ -1,7 +1,7 @@ require "test/support/helper/spec/shared_examples/hbc_dsl_base" describe Hbc::DSL::UninstallPostflight, :cask do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("basic-cask")) } let(:dsl) { Hbc::DSL::UninstallPostflight.new(cask, Hbc::FakeSystemCommand) } it_behaves_like Hbc::DSL::Base diff --git a/Library/Homebrew/test/cask/dsl/uninstall_preflight_spec.rb b/Library/Homebrew/test/cask/dsl/uninstall_preflight_spec.rb index 15a0ea156..8e7fa47eb 100644 --- a/Library/Homebrew/test/cask/dsl/uninstall_preflight_spec.rb +++ b/Library/Homebrew/test/cask/dsl/uninstall_preflight_spec.rb @@ -2,7 +2,7 @@ require "test/support/helper/spec/shared_examples/hbc_dsl_base" require "test/support/helper/spec/shared_examples/hbc_staged" describe Hbc::DSL::UninstallPreflight, :cask do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/basic-cask.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("basic-cask")) } let(:dsl) { Hbc::DSL::UninstallPreflight.new(cask, Hbc::FakeSystemCommand) } it_behaves_like Hbc::DSL::Base diff --git a/Library/Homebrew/test/cask/dsl_spec.rb b/Library/Homebrew/test/cask/dsl_spec.rb index 7df8de6f8..27d9f1afd 100644 --- a/Library/Homebrew/test/cask/dsl_spec.rb +++ b/Library/Homebrew/test/cask/dsl_spec.rb @@ -1,5 +1,5 @@ describe Hbc::DSL, :cask do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/#{token}.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path(token.to_s)) } let(:token) { "basic-cask" } context "stanzas" do diff --git a/Library/Homebrew/test/cask/installer_spec.rb b/Library/Homebrew/test/cask/installer_spec.rb index 6f7c6d3d7..2dc27f04c 100644 --- a/Library/Homebrew/test/cask/installer_spec.rb +++ b/Library/Homebrew/test/cask/installer_spec.rb @@ -5,7 +5,7 @@ describe Hbc::Installer, :cask do } it "downloads and installs a nice fresh Cask" do - caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") + caffeine = Hbc::CaskLoader.load(cask_path("local-caffeine")) Hbc::Installer.new(caffeine).install @@ -14,7 +14,7 @@ describe Hbc::Installer, :cask do end it "works with dmg-based Casks" do - asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-dmg.rb") + asset = Hbc::CaskLoader.load(cask_path("container-dmg")) Hbc::Installer.new(asset).install @@ -23,7 +23,7 @@ describe Hbc::Installer, :cask do end it "works with tar-gz-based Casks" do - asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-tar-gz.rb") + asset = Hbc::CaskLoader.load(cask_path("container-tar-gz")) Hbc::Installer.new(asset).install @@ -32,7 +32,7 @@ describe Hbc::Installer, :cask do end it "works with xar-based Casks" do - asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-xar.rb") + asset = Hbc::CaskLoader.load(cask_path("container-xar")) Hbc::Installer.new(asset).install @@ -41,7 +41,7 @@ describe Hbc::Installer, :cask do end it "works with pure bzip2-based Casks" do - asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-bzip2.rb") + asset = Hbc::CaskLoader.load(cask_path("container-bzip2")) Hbc::Installer.new(asset).install @@ -50,7 +50,7 @@ describe Hbc::Installer, :cask do end it "works with pure gzip-based Casks" do - asset = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-gzip.rb") + asset = Hbc::CaskLoader.load(cask_path("container-gzip")) Hbc::Installer.new(asset).install @@ -59,21 +59,21 @@ describe Hbc::Installer, :cask do end it "blows up on a bad checksum" do - bad_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/bad-checksum.rb") + bad_checksum = Hbc::CaskLoader.load(cask_path("bad-checksum")) expect { Hbc::Installer.new(bad_checksum).install }.to raise_error(Hbc::CaskSha256MismatchError) end it "blows up on a missing checksum" do - missing_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/missing-checksum.rb") + missing_checksum = Hbc::CaskLoader.load(cask_path("missing-checksum")) expect { Hbc::Installer.new(missing_checksum).install }.to raise_error(Hbc::CaskSha256MissingError) end it "installs fine if sha256 :no_check is used" do - no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb") + no_checksum = Hbc::CaskLoader.load(cask_path("no-checksum")) Hbc::Installer.new(no_checksum).install @@ -81,14 +81,14 @@ describe Hbc::Installer, :cask do end it "fails to install if sha256 :no_check is used with --require-sha" do - no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb") + no_checksum = Hbc::CaskLoader.load(cask_path("no-checksum")) expect { Hbc::Installer.new(no_checksum, require_sha: true).install }.to raise_error(Hbc::CaskNoShasumError) end it "installs fine if sha256 :no_check is used with --require-sha and --force" do - no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb") + no_checksum = Hbc::CaskLoader.load(cask_path("no-checksum")) Hbc::Installer.new(no_checksum, require_sha: true, force: true).install @@ -96,7 +96,7 @@ describe Hbc::Installer, :cask do end it "prints caveats if they're present" do - with_caveats = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-caveats.rb") + with_caveats = Hbc::CaskLoader.load(cask_path("with-caveats")) expect { Hbc::Installer.new(with_caveats).install @@ -106,7 +106,7 @@ describe Hbc::Installer, :cask do end it "prints installer :manual instructions when present" do - with_installer_manual = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installer-manual.rb") + with_installer_manual = Hbc::CaskLoader.load(cask_path("with-installer-manual")) expect { Hbc::Installer.new(with_installer_manual).install @@ -116,7 +116,7 @@ describe Hbc::Installer, :cask do end it "does not extract __MACOSX directories from zips" do - with_macosx_dir = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-macosx-dir.rb") + with_macosx_dir = Hbc::CaskLoader.load(cask_path("with-macosx-dir")) Hbc::Installer.new(with_macosx_dir).install @@ -124,7 +124,7 @@ describe Hbc::Installer, :cask do end it "allows already-installed Casks which auto-update to be installed if force is provided" do - with_auto_updates = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb") + with_auto_updates = Hbc::CaskLoader.load(cask_path("auto-updates")) expect(with_auto_updates).not_to be_installed @@ -137,7 +137,7 @@ describe Hbc::Installer, :cask 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::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") + transmission = Hbc::CaskLoader.load(cask_path("local-transmission")) expect(transmission).not_to be_installed @@ -151,7 +151,7 @@ describe Hbc::Installer, :cask do end it "allows already-installed Casks to be installed if force is provided" do - transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") + transmission = Hbc::CaskLoader.load(cask_path("local-transmission")) expect(transmission).not_to be_installed @@ -163,7 +163,7 @@ describe Hbc::Installer, :cask do end it "works naked-pkg-based Casks" do - naked_pkg = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/container-pkg.rb") + naked_pkg = Hbc::CaskLoader.load(cask_path("container-pkg")) Hbc::Installer.new(naked_pkg).install @@ -171,7 +171,7 @@ describe Hbc::Installer, :cask do end it "works properly with an overridden container :type" do - naked_executable = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/naked-executable.rb") + naked_executable = Hbc::CaskLoader.load(cask_path("naked-executable")) Hbc::Installer.new(naked_executable).install @@ -179,7 +179,7 @@ describe Hbc::Installer, :cask do end it "works fine with a nested container" do - nested_app = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/nested-app.rb") + nested_app = Hbc::CaskLoader.load(cask_path("nested-app")) Hbc::Installer.new(nested_app).install @@ -187,7 +187,7 @@ describe Hbc::Installer, :cask do end it "generates and finds a timestamped metadata directory for an installed Cask" do - caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") + caffeine = Hbc::CaskLoader.load(cask_path("local-caffeine")) Hbc::Installer.new(caffeine).install @@ -196,7 +196,7 @@ describe Hbc::Installer, :cask do end it "generates and finds a metadata subdirectory for an installed Cask" do - caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") + caffeine = Hbc::CaskLoader.load(cask_path("local-caffeine")) Hbc::Installer.new(caffeine).install @@ -208,7 +208,7 @@ describe Hbc::Installer, :cask do describe "uninstall" do it "fully uninstalls a Cask" do - caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") + caffeine = Hbc::CaskLoader.load(cask_path("local-caffeine")) installer = Hbc::Installer.new(caffeine) installer.install @@ -220,7 +220,7 @@ describe Hbc::Installer, :cask do end it "uninstalls all versions if force is set" do - caffeine = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") + caffeine = Hbc::CaskLoader.load(cask_path("local-caffeine")) mutated_version = caffeine.version + ".1" Hbc::Installer.new(caffeine).install diff --git a/Library/Homebrew/test/cask/staged_spec.rb b/Library/Homebrew/test/cask/staged_spec.rb index 73a909f35..0229018c7 100644 --- a/Library/Homebrew/test/cask/staged_spec.rb +++ b/Library/Homebrew/test/cask/staged_spec.rb @@ -3,7 +3,7 @@ # to be invoking bundle_identifier off of the installer instance. describe "Operations on staged Casks", :cask do describe "bundle ID" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb") } + let(:cask) { Hbc::CaskLoader.load(cask_path("local-transmission")) } let(:installer) { Hbc::Installer.new(cask) } it "fetches the bundle ID from a staged cask" do installer.install diff --git a/Library/Homebrew/test/support/helper/fixtures.rb b/Library/Homebrew/test/support/helper/fixtures.rb index 716fe2008..460fb4aef 100644 --- a/Library/Homebrew/test/support/helper/fixtures.rb +++ b/Library/Homebrew/test/support/helper/fixtures.rb @@ -8,6 +8,10 @@ module Test def bundle_path(name) Pathname.new("#{TEST_FIXTURE_DIR}/mach/#{name}.bundle") end + + def cask_path(name) + Pathname.new("#{TEST_FIXTURE_DIR}/cask/Casks/#{name}.rb") + end end end end |
