From 9e509d289bca6926256ccb71a8fc0cf3bcfabb38 Mon Sep 17 00:00:00 2001 From: phinze Date: Sun, 18 Nov 2012 12:17:50 -0600 Subject: [PATCH] uninstall no longer depends uses homebrew - should make tests a bit more reliable --- lib/cask/cli/uninstall.rb | 4 +++- lib/cask/installer.rb | 13 +++---------- test/cli/uninstall_test.rb | 16 +++++----------- 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/lib/cask/cli/uninstall.rb b/lib/cask/cli/uninstall.rb index 3ffb5f56d..5de3aae6e 100644 --- a/lib/cask/cli/uninstall.rb +++ b/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 diff --git a/lib/cask/installer.rb b/lib/cask/installer.rb index 8e843f737..6f5325a16 100644 --- a/lib/cask/installer.rb +++ b/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) diff --git a/test/cli/uninstall_test.rb b/test/cli/uninstall_test.rb index 4a3dbf1a5..d620b28ce 100644 --- a/test/cli/uninstall_test.rb +++ b/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