Browse Source

uninstall no longer depends uses homebrew

- should make tests a bit more reliable
phinze 12 years ago
parent
commit
9e509d289b
  1. 4
      lib/cask/cli/uninstall.rb
  2. 13
      lib/cask/installer.rb
  3. 16
      test/cli/uninstall_test.rb

4
lib/cask/cli/uninstall.rb

@ -2,7 +2,9 @@ class Cask::CLI::Uninstall
def self.run(*cask_names)
begin
casks = cask_names.map { |cn| Cask.load(cn) }
Cask::Installer.uninstall(*casks)
casks.each do |cask|
Cask::Installer.uninstall(cask)
end
rescue CaskUnavailableError,CaskNotInstalledError => e
onoe e
end

13
lib/cask/installer.rb

@ -14,17 +14,10 @@ class Cask::Installer
ohai "Success! #{cask} installed to #{cask.destination_path}"
end
def uninstall(*casks)
casks.each do |cask|
raise CaskNotInstalledError.new(cask) unless cask.installed?
end
def uninstall(cask)
raise CaskNotInstalledError.new(cask) unless cask.installed?
require 'cmd/uninstall'
ARGV.clear
casks.each do |cask|
ARGV << cask.title
end
Homebrew.uninstall
cask.destination_path.rmtree
end
def _with_extracted_mountpoints(path)

16
test/cli/uninstall_test.rb

@ -25,19 +25,13 @@ describe Cask::CLI::Uninstall do
end
it "can uninstall multiple casks at once" do
caffeine = Cask.load('caffeine')
anvil = Cask.load('anvil')
shutup do
Cask::Installer.install(caffeine)
Cask::Installer.install(anvil)
Cask::Installer.expects(:uninstall).with do |cask|
cask.title == 'caffeine'
end
shutup do
Cask::CLI::Uninstall.run('caffeine', 'anvil')
Cask::Installer.expects(:uninstall).with do |cask|
cask.title == 'anvil'
end
caffeine.wont_be :installed?
anvil.wont_be :installed?
Cask::CLI::Uninstall.run('caffeine', 'anvil')
end
end

Loading…
Cancel
Save