brew/Library/Homebrew/test/cask/artifact/installer_spec.rb
Issy Long 3a83b5492c
rubocop: Clean up Style/BlockDelimiters excludes and autofix offenses
- The defaults of using "do ... end" for multi-line blocks everywhere is
  good, better than switching everything to braces everywhere.
2023-03-08 23:54:22 +00:00

46 lines
1.2 KiB
Ruby

# typed: false
# frozen_string_literal: true
describe Cask::Artifact::Installer, :cask do
subject(:installer) { described_class.new(cask, **args) }
let(:staged_path) { mktmpdir }
let(:cask) { instance_double(Cask::Cask, staged_path: staged_path) }
let(:command) { SystemCommand }
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
installer.install_phase(command: command)
end.to output(%r{run the installer at:\s+#{staged_path}/installer}).to_stdout
end
end
context "when given a script installer" do
let(:executable) { staged_path/"executable" }
let(:args) { { script: { executable: "executable" } } }
before do
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")) },
),
)
installer.install_phase(command: command)
end
end
end
end