From c1bb87e2ac6b5d9199ebfaac40b8c13fac871827 Mon Sep 17 00:00:00 2001 From: Josh Hagins Date: Sat, 2 Jan 2016 20:09:25 -0500 Subject: [PATCH] Extract tests specific to uninstall :quit --- test/cask/artifact/uninstall_test.rb | 20 +++++++++++++++++++- test/support/Casks/with-uninstall-quit.rb | 11 +++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 test/support/Casks/with-uninstall-quit.rb diff --git a/test/cask/artifact/uninstall_test.rb b/test/cask/artifact/uninstall_test.rb index 9bf9d3685f7..bee52aa6876 100644 --- a/test/cask/artifact/uninstall_test.rb +++ b/test/cask/artifact/uninstall_test.rb @@ -196,7 +196,25 @@ describe Hbc::Artifact::Uninstall do end describe 'when using quit' do - # todo + let(:cask) { Hbc.load('with-uninstall-quit') } + let(:bundle_id) { 'my.fancy.package.app' } + let(:count_processes_script) { + 'tell application "System Events" to count processes ' + + %Q{whose bundle identifier is "#{bundle_id}"} + } + let(:quit_application_script) { + %Q{tell application id "#{bundle_id}" to quit} + } + + it 'can uninstall' do + Hbc::FakeSystemCommand.stubs_command( + sudo(%W[/usr/bin/osascript -e #{count_processes_script}]), '1') + + Hbc::FakeSystemCommand.stubs_command( + sudo(%W[/usr/bin/osascript -e #{quit_application_script}])) + + subject + end end describe 'when using signal' do diff --git a/test/support/Casks/with-uninstall-quit.rb b/test/support/Casks/with-uninstall-quit.rb new file mode 100644 index 00000000000..f41ed868bbd --- /dev/null +++ b/test/support/Casks/with-uninstall-quit.rb @@ -0,0 +1,11 @@ +test_cask 'with-uninstall-quit' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url TestHelper.local_binary_url('MyFancyPkg.zip') + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg' + + uninstall :quit => 'my.fancy.package.app' +end