diff options
| author | Markus Reiter | 2017-03-14 00:21:37 +0100 |
|---|---|---|
| committer | GitHub | 2017-03-14 00:21:37 +0100 |
| commit | cdccb24ae03b67f371f9bc81f468cdfaafa6b421 (patch) | |
| tree | 813c3b1993c2c88651fda7ef51e942832eb1f91a /Library/Homebrew/test | |
| parent | b7e7b5b5c9eb2b4282fb1913fc59d85f9e1ac140 (diff) | |
| parent | 2b4c3ee1d75199c7886905f4ee678e7dd437b5e0 (diff) | |
| download | brew-cdccb24ae03b67f371f9bc81f468cdfaafa6b421.tar.bz2 | |
Merge pull request #2330 from reitermarkus/sudo-false
Default to `sudo: false` for `installer/uninstall :script`.
Diffstat (limited to 'Library/Homebrew/test')
| -rw-r--r-- | Library/Homebrew/test/cask/artifact/uninstall_zap_shared_examples.rb | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/Library/Homebrew/test/cask/artifact/uninstall_zap_shared_examples.rb b/Library/Homebrew/test/cask/artifact/uninstall_zap_shared_examples.rb index 69e015489..6c2fd1a05 100644 --- a/Library/Homebrew/test/cask/artifact/uninstall_zap_shared_examples.rb +++ b/Library/Homebrew/test/cask/artifact/uninstall_zap_shared_examples.rb @@ -216,35 +216,32 @@ shared_examples "#uninstall_phase or #zap_phase" do end end - context "using :script" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-#{artifact_name}-script.rb") } - let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") } - - it "is supported" do - Hbc::FakeSystemCommand.expects_command(%w[/bin/chmod -- +x] + [script_pathname]) - - Hbc::FakeSystemCommand.expects_command( - sudo(cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool"), "--please"), - ) - - InstallHelper.install_without_artifacts(cask) - subject - end - end - - context "using :early_script" do - let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-#{artifact_name}-early-script.rb") } - let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") } - - it "is supported" do - Hbc::FakeSystemCommand.expects_command(%w[/bin/chmod -- +x] + [script_pathname]) - - Hbc::FakeSystemCommand.expects_command( - sudo(cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool"), "--please"), - ) + [:script, :early_script].each do |script_type| + context "using #{script_type.inspect}" do + let(:fake_system_command) { Hbc::NeverSudoSystemCommand } + let(:token) { "with-#{artifact_name}-#{script_type}".tr("_", "-") } + let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/#{token}.rb") } + let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") } - InstallHelper.install_without_artifacts(cask) - subject + it "is supported" do + allow(fake_system_command).to receive(:run).with(any_args).and_call_original + + expect(fake_system_command).to receive(:run).with( + "/bin/chmod", + args: ["--", "+x", script_pathname], + ) + + expect(fake_system_command).to receive(:run).with( + cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool"), + args: ["--please"], + must_succeed: true, + print_stdout: true, + sudo: false, + ) + + InstallHelper.install_without_artifacts(cask) + subject + end end end |
