From 05cb6cda088d740e2cfa204da2ba36a68f503afc Mon Sep 17 00:00:00 2001 From: Markus Reiter <me@reitermark.us> Date: Wed, 11 Jul 2018 15:22:37 +0200 Subject: [PATCH] Add `Installer` spec. --- .../test/cask/artifact/installer_spec.rb | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Library/Homebrew/test/cask/artifact/installer_spec.rb diff --git a/Library/Homebrew/test/cask/artifact/installer_spec.rb b/Library/Homebrew/test/cask/artifact/installer_spec.rb new file mode 100644 index 0000000000..7e4c551125 --- /dev/null +++ b/Library/Homebrew/test/cask/artifact/installer_spec.rb @@ -0,0 +1,40 @@ +describe Hbc::Artifact::Installer, :cask do + let(:staged_path) { mktmpdir } + let(:cask) { instance_double("Cask", staged_path: staged_path, config: nil) } + subject(:installer) { described_class.new(cask, **args) } + let(:command) { Hbc::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 { + installer.install_phase(command: command) + }.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(:each) 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["PATH"]) }, + ), + ) + + installer.install_phase(command: command) + end + end + end +end -- GitLab