brew/Library/Homebrew/test/cask/artifact/installer_spec.rb

45 lines
1.2 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2018-09-06 08:29:14 +02:00
describe Cask::Artifact::Installer, :cask do
2018-09-20 09:07:56 +01:00
subject(:installer) { described_class.new(cask, **args) }
2018-07-11 15:22:37 +02:00
let(:staged_path) { mktmpdir }
let(:cask) { instance_double(Cask::Cask, staged_path: staged_path) }
2018-09-20 09:07:56 +01:00
let(:command) { SystemCommand }
2018-07-11 15:22:37 +02:00
let(:args) { {} }
describe "#install_phase" do
context "when given a manual installer" do
let(:args) { { manual: "installer" } }
it "shows a message prompting to run the installer manually" do
expect do
2018-07-11 15:22:37 +02:00
installer.install_phase(command: command)
2023-04-14 20:07:01 +02:00
end.to output(%r{open #{staged_path}/installer}).to_stdout
2018-07-11 15:22:37 +02:00
end
end
context "when given a script installer" do
let(:executable) { staged_path/"executable" }
let(:args) { { script: { executable: "executable" } } }
2018-09-20 09:07:56 +01:00
before do
2018-07-11 15:22:37 +02:00
FileUtils.touch executable
end
it "looks for the executable in HOMEBREW_PREFIX" do
expect(command).to receive(:run!).with(
executable,
a_hash_including(
env: { "PATH" => PATH.new("#{HOMEBREW_PREFIX}/bin", "#{HOMEBREW_PREFIX}/sbin", ENV.fetch("PATH")) },
2018-07-11 15:22:37 +02:00
),
)
installer.install_phase(command: command)
end
end
end
end