homebrew-cask-versions/test/cask/cli/zap_test.rb
Roland Walker 967aa22793 recast method destination_path as staged_path
* part of DSL 1.0 review
* `destination_path` was always a bit vague (it refers to
  Cask-specific, version-specific location under
  `/opt/homebrew-cask/Caskroom`)
* here renamed `staged_path` to match upcoming command verb
  `brew cask stage`
* rename also intended to reduce confusion when we implement
  copying as a configurable alternative to symlinking
* transitional `destination_path` methods to remain while
  Casks are converted (this was documented as a part of the
  DSL, and used by 39 Casks in main repo)
* unrelated variables containing "stage" recast for clarity
2014-10-18 12:23:36 -04:00

76 lines
2.8 KiB
Ruby

require 'test_helper'
describe Cask::CLI::Zap do
it "shows an error when a bad Cask is provided" do
lambda {
Cask::CLI::Zap.run('notacask')
}.must_raise CaskUnavailableError
end
it "can zap and unlink multiple Casks at once" do
caffeine = Cask.load('local-caffeine')
transmission = Cask.load('local-transmission')
shutup do
Cask::Installer.new(caffeine).install
Cask::Installer.new(transmission).install
end
caffeine.must_be :installed?
transmission.must_be :installed?
shutup do
Cask::CLI::Zap.run('--notavalidoption',
'local-caffeine', 'local-transmission')
end
caffeine.wont_be :installed?
Cask.appdir.join('Transmission.app').wont_be :symlink?
transmission.wont_be :installed?
Cask.appdir.join('Caffeine.app').wont_be :symlink?
end
# todo
# Explicit test that both zap and uninstall directives get dispatched.
# The above tests that implicitly.
#
# it "dispatches both uninstall and zap stanzas" do
# with_zap = Cask.load('with-zap')
#
# shutup do
# Cask::Installer.new(with_zap).install
# end
#
# with_zap.must_be :installed?
#
# Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app"'], '1')
# Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application id "my.fancy.package.app" to quit'])
# Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app.from.uninstall"'], '1')
# Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application id "my.fancy.package.app.from.uninstall" to quit'])
#
# Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', with_zap.staged_path/'MyFancyPkg'/'FancyUninstaller.tool', '--please'])
# Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-rf', '--',
# Pathname.new('~/Library/Preferences/my.fancy.app.plist').expand_path])
#
# shutup do
# Cask::CLI::Zap.run('with-zap')
# end
# with_zap.wont_be :installed?
# end
describe "when no Cask is specified" do
it "raises an exception" do
lambda {
Cask::CLI::Zap.run()
}.must_raise CaskUnspecifiedError
end
end
describe "when no Cask is specified, but an invalid option" do
it "raises an exception" do
lambda {
Cask::CLI::Zap.run('--notavalidoption')
}.must_raise CaskUnspecifiedError
end
end
end