aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/cask/artifact/preflight_block_spec.rb
blob: b13c4ab9d32f6d51b6505a471e73d5911757267e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
describe Hbc::Artifact::PreflightBlock, :cask do
  describe "install_phase" do
    it "calls the specified block before installing, passing a Cask mini-dsl" do
      called = false
      yielded_arg = nil

      cask = Hbc::Cask.new("with-preflight") do
        preflight do |c|
          called = true
          yielded_arg = c
        end
      end

      described_class.new(cask).install_phase

      expect(called).to be true
      expect(yielded_arg).to be_kind_of Hbc::DSL::Preflight
    end
  end

  describe "uninstall_phase" do
    it "calls the specified block before uninstalling, passing a Cask mini-dsl" do
      called = false
      yielded_arg = nil

      cask = Hbc::Cask.new("with-uninstall-preflight") do
        uninstall_preflight do |c|
          called = true
          yielded_arg = c
        end
      end

      described_class.new(cask).uninstall_phase

      expect(called).to be true
      expect(yielded_arg).to be_kind_of Hbc::DSL::UninstallPreflight
    end
  end
end