Skip to content

Commit

Permalink
Manual fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dduugg committed Feb 11, 2024
1 parent 2be13eb commit 7e66f4c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
let(:artifact) { cask.artifacts.find { |a| a.is_a?(described_class) } }
let(:fake_system_command) { class_double(SystemCommand) }

context "using :launchctl" do
context "when using :launchctl" do
let(:cask) { Cask::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-launchctl")) }
let(:launchctl_list_cmd) { %w[/bin/launchctl list my.fancy.package.service] }
let(:launchctl_remove_cmd) { %w[/bin/launchctl remove my.fancy.package.service] }
Expand Down Expand Up @@ -84,7 +84,7 @@
end
end

context "using :launchctl with regex wildcard" do
context "when using :launchctl with regex wildcard" do
let(:cask) { Cask::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-launchctl-wildcard")) }
let(:launchctl_regex) { "my.fancy.package.service.*" }
let(:unknown_response) { "launchctl list returned unknown response\n" }
Expand Down Expand Up @@ -154,7 +154,7 @@
end
end

context "using :pkgutil" do
context "when using :pkgutil" do
let(:cask) { Cask::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-pkgutil")) }

let(:main_pkg_id) { "my.fancy.package.main" }
Expand All @@ -178,7 +178,7 @@
end
end

context "using :kext" do
context "when using :kext" do
let(:cask) { Cask::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-kext")) }
let(:kext_id) { "my.fancy.package.kernelextension" }

Expand All @@ -202,7 +202,7 @@
end
end

context "using :quit" do
context "when using :quit" do
let(:cask) { Cask::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-quit")) }
let(:bundle_id) { "my.fancy.package.app" }

Expand Down Expand Up @@ -236,10 +236,8 @@
expect(subject).not_to receive(:running?)
expect(subject).not_to receive(:quit)

expect do
subject.public_send(:"#{artifact_dsl_key}_phase", upgrade: true, command: fake_system_command)
subject.public_send(:"#{artifact_dsl_key}_phase", reinstall: true, command: fake_system_command)
end
subject.public_send(:"#{artifact_dsl_key}_phase", upgrade: true, command: fake_system_command)
subject.public_send(:"#{artifact_dsl_key}_phase", reinstall: true, command: fake_system_command)
end

it "tries to quit the application for 10 seconds" do
Expand All @@ -259,7 +257,7 @@
end
end

context "using :signal" do
context "when using :signal" do
let(:cask) { Cask::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-signal")) }
let(:bundle_id) { "my.fancy.package.app" }
let(:signals) { %w[TERM KILL] }
Expand Down Expand Up @@ -294,13 +292,13 @@
[:delete, :trash].each do |directive|
next if directive == :trash && ENV["HOMEBREW_TESTS_COVERAGE"].nil?

context "using :#{directive}" do
context "when using :#{directive}" do
let(:dir) { TEST_TMPDIR }
let(:absolute_path) { Pathname.new("#{dir}/absolute_path") }
let(:path_with_tilde) { Pathname.new("#{dir}/path_with_tilde") }
let(:glob_path1) { Pathname.new("#{dir}/glob_path1") }
let(:glob_path2) { Pathname.new("#{dir}/glob_path2") }
let(:paths) { [absolute_path, path_with_tilde, glob_path1, glob_path2] }
let(:glob_path_) { Pathname.new("#{dir}/glob_path_") }
let(:paths) { [absolute_path, path_with_tilde, glob_path1, glob_path_] }
let(:fake_system_command) { NeverSudoSystemCommand }
let(:cask) { Cask::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-#{directive}")) }

Expand Down Expand Up @@ -336,7 +334,7 @@
end

[:script, :early_script].each do |script_type|
context "using #{script_type.inspect}" do
context "when using #{script_type.inspect}" do
let(:fake_system_command) { NeverSudoSystemCommand }
let(:token) { "with-#{artifact_dsl_key}-#{script_type}".tr("_", "-") }
let(:cask) { Cask::CaskLoader.load(cask_path(token.to_s)) }
Expand All @@ -360,7 +358,7 @@
end
end

context "using :login_item" do
context "when using :login_item" do
let(:cask) { Cask::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-login-item")) }

it "is supported" do
Expand Down
3 changes: 2 additions & 1 deletion Library/Homebrew/test/cask/dsl/shared_examples/staged.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
it "cannot set the permissions of a file that does not exist" do
fake_pathname = non_existent_path
allow(staged).to receive(:Pathname).and_return(fake_pathname)
expect(fake_system_command).not_to receive(:run!)
staged.set_permissions(fake_pathname.to_s, "777")
end

Expand Down Expand Up @@ -91,7 +92,7 @@
allow(User).to receive(:current).and_return(User.new("fake_user"))
fake_pathname = non_existent_path
allow(staged).to receive(:Pathname).and_return(fake_pathname)

expect(fake_system_command).not_to receive(:run!)
staged.set_ownership(fake_pathname.to_s)
end
end
2 changes: 1 addition & 1 deletion Library/Homebrew/test/support/helper/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def formula(name = "formula_name", path: Formulary.core_path(name), spec: :stabl
def stub_formula_loader(formula, ref = formula.full_name, call_original: false)
allow(Formulary).to receive(:loader_for).and_call_original if call_original

loader = double(get_formula: formula)
loader = instance_double(Formulary::FormulaLoader, get_formula: formula)
allow(Formulary).to receive(:loader_for).with(ref, any_args).and_return(loader)
end
end
Expand Down

0 comments on commit 7e66f4c

Please sign in to comment.