brew style --fix

This commit is contained in:
Douglas Eichelberger 2024-02-11 14:26:06 -08:00
parent ee08fc53c1
commit 2be13eb715
2 changed files with 8 additions and 12 deletions

View File

@ -185,15 +185,15 @@ shared_examples "#uninstall_phase or #zap_phase" do
it "is supported" do it "is supported" do
allow(subject).to receive(:system_command!) allow(subject).to receive(:system_command!)
.with("/usr/sbin/kextstat", args: ["-l", "-b", kext_id], sudo: true, sudo_as_root: true) .with("/usr/sbin/kextstat", args: ["-l", "-b", kext_id], sudo: true, sudo_as_root: true)
.and_return(instance_double("SystemCommand::Result", stdout: "loaded")) .and_return(instance_double(SystemCommand::Result, stdout: "loaded"))
expect(subject).to receive(:system_command!) expect(subject).to receive(:system_command!)
.with("/sbin/kextunload", args: ["-b", kext_id], sudo: true, sudo_as_root: true) .with("/sbin/kextunload", args: ["-b", kext_id], sudo: true, sudo_as_root: true)
.and_return(instance_double("SystemCommand::Result")) .and_return(instance_double(SystemCommand::Result))
expect(subject).to receive(:system_command!) expect(subject).to receive(:system_command!)
.with("/usr/sbin/kextfind", args: ["-b", kext_id], sudo: true, sudo_as_root: true) .with("/usr/sbin/kextfind", args: ["-b", kext_id], sudo: true, sudo_as_root: true)
.and_return(instance_double("SystemCommand::Result", stdout: "/Library/Extensions/FancyPackage.kext\n")) .and_return(instance_double(SystemCommand::Result, stdout: "/Library/Extensions/FancyPackage.kext\n"))
expect(subject).to receive(:system_command!) expect(subject).to receive(:system_command!)
.with("/bin/rm", args: ["-rf", "/Library/Extensions/FancyPackage.kext"], sudo: true, sudo_as_root: true) .with("/bin/rm", args: ["-rf", "/Library/Extensions/FancyPackage.kext"], sudo: true, sudo_as_root: true)
@ -220,7 +220,7 @@ shared_examples "#uninstall_phase or #zap_phase" do
expect(subject).to receive(:running?).with(bundle_id).ordered.and_return(true) expect(subject).to receive(:running?).with(bundle_id).ordered.and_return(true)
expect(subject).to receive(:quit).with(bundle_id) expect(subject).to receive(:quit).with(bundle_id)
.and_return(instance_double("SystemCommand::Result", success?: true)) .and_return(instance_double(SystemCommand::Result, success?: true))
expect(subject).to receive(:running?).with(bundle_id).ordered.and_return(false) expect(subject).to receive(:running?).with(bundle_id).ordered.and_return(false)
expect do expect do
@ -247,7 +247,7 @@ shared_examples "#uninstall_phase or #zap_phase" do
allow(subject).to receive(:running?).with(bundle_id).and_return(true) allow(subject).to receive(:running?).with(bundle_id).and_return(true)
allow(subject).to receive(:quit).with(bundle_id) allow(subject).to receive(:quit).with(bundle_id)
.and_return(instance_double("SystemCommand::Result", success?: false)) .and_return(instance_double(SystemCommand::Result, success?: false))
time = Benchmark.measure do time = Benchmark.measure do
expect do expect do
@ -369,7 +369,7 @@ shared_examples "#uninstall_phase or #zap_phase" do
"osascript", "osascript",
args: ["-e", 'tell application "System Events" to delete every login item whose name is "Fancy"'], args: ["-e", 'tell application "System Events" to delete every login item whose name is "Fancy"'],
) )
.and_return(instance_double("SystemCommand::Result", success?: true)) .and_return(instance_double(SystemCommand::Result, success?: true))
subject.public_send(:"#{artifact_dsl_key}_phase", command: fake_system_command) subject.public_send(:"#{artifact_dsl_key}_phase", command: fake_system_command)
end end

View File

@ -7,12 +7,8 @@ shared_examples Cask::Staged do
let(:non_existent_path) { Pathname("/path/to/file/that/does/not/exist") } let(:non_existent_path) { Pathname("/path/to/file/that/does/not/exist") }
before do before do
allow(existing_path).to receive(:exist?).and_return(true) allow(existing_path).to receive_messages(exist?: true, expand_path: existing_path)
allow(existing_path).to receive(:expand_path) allow(non_existent_path).to receive_messages(exist?: false, expand_path: non_existent_path)
.and_return(existing_path)
allow(non_existent_path).to receive(:exist?).and_return(false)
allow(non_existent_path).to receive(:expand_path)
.and_return(non_existent_path)
end end
it "can run system commands with list-form arguments" do it "can run system commands with list-form arguments" do