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

46 lines
1.2 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2018-09-06 08:29:14 +02:00
describe Cask::Artifact::PreflightBlock, :cask do
2016-08-18 22:11:42 +03:00
describe "install_phase" do
it "calls the specified block before installing, passing a Cask mini-dsl" do
called = false
2016-08-18 22:11:42 +03:00
yielded_arg = nil
2018-09-06 08:29:14 +02:00
cask = Cask::Cask.new("with-preflight") do
2016-08-18 22:11:42 +03:00
preflight do |c|
called = true
yielded_arg = c
end
end
2017-10-04 17:54:52 +02:00
cask.artifacts.select { |a| a.is_a?(described_class) }.each do |artifact|
artifact.install_phase(command: NeverSudoSystemCommand, force: false)
2017-10-04 17:54:52 +02:00
end
2016-08-18 22:11:42 +03:00
expect(called).to be true
2022-09-13 09:43:09 +01:00
expect(yielded_arg).to be_a Cask::DSL::Preflight
2016-08-18 22:11:42 +03:00
end
end
describe "uninstall_phase" do
it "calls the specified block before uninstalling, passing a Cask mini-dsl" do
called = false
2016-08-18 22:11:42 +03:00
yielded_arg = nil
2018-09-06 08:29:14 +02:00
cask = Cask::Cask.new("with-uninstall-preflight") do
2016-08-18 22:11:42 +03:00
uninstall_preflight do |c|
called = true
yielded_arg = c
end
end
2017-10-04 17:54:52 +02:00
cask.artifacts.select { |a| a.is_a?(described_class) }.each do |artifact|
artifact.uninstall_phase(command: NeverSudoSystemCommand, force: false)
2017-10-04 17:54:52 +02:00
end
2016-08-18 22:11:42 +03:00
expect(called).to be true
2022-09-13 09:43:09 +01:00
expect(yielded_arg).to be_a Cask::DSL::UninstallPreflight
2016-08-18 22:11:42 +03:00
end
end
end