Browse Source
this delegates to homebrew's uninstall to get its work done. vanilla `brew uninstall` actually works, but this gives us a more consistent interface. as discussed in #47
11 changed files with 116 additions and 36 deletions
@ -0,0 +1,16 @@ |
|||
class Cask::CLI::Uninstall |
|||
def self.run(*cask_names) |
|||
cask_names.each do |cask_name| |
|||
begin |
|||
cask = Cask.load(cask_name) |
|||
Cask::Installer.uninstall(cask) |
|||
rescue CaskUnavailableError,CaskNotInstalledError => e |
|||
onoe e |
|||
end |
|||
end |
|||
end |
|||
|
|||
def self.help |
|||
"uninstalls the cask of the given name" |
|||
end |
|||
end |
@ -0,0 +1,35 @@ |
|||
require 'test_helper' |
|||
|
|||
describe Cask::Installer do |
|||
describe "install" do |
|||
it "downloads and installs a nice fresh Cask" do |
|||
caffeine = Cask.load('caffeine') |
|||
|
|||
shutup do |
|||
Cask::Installer.install(caffeine) |
|||
end |
|||
|
|||
dest_path = HOMEBREW_CELLAR/'caffeine'/caffeine.version |
|||
dest_path.must_be :directory? |
|||
application = dest_path/'Caffeine.app' |
|||
application.must_be :directory? |
|||
end |
|||
end |
|||
|
|||
describe "uninstall" do |
|||
it "fully uninstalls a cask" do |
|||
caffeine = Cask.load('caffeine') |
|||
|
|||
shutup do |
|||
Cask::Installer.install(caffeine) |
|||
Cask::Installer.uninstall(caffeine) |
|||
end |
|||
|
|||
dest_path = HOMEBREW_CELLAR/'caffeine'/caffeine.version |
|||
application = dest_path/'Caffeine.app' |
|||
|
|||
application.wont_be :directory? |
|||
dest_path.wont_be :directory? |
|||
end |
|||
end |
|||
end |
@ -0,0 +1,26 @@ |
|||
require 'test_helper' |
|||
|
|||
describe Cask::CLI::Uninstall do |
|||
it "shows an error when a bad cask is provided" do |
|||
lambda { |
|||
Cask::CLI::Uninstall.run('notacask') |
|||
}.must_output <<-OUTPUT.gsub(/^ */, '') |
|||
Error: No available cask for notacask |
|||
OUTPUT |
|||
end |
|||
|
|||
it "shows an error when a cask is provided that's not installed" do |
|||
lambda { |
|||
Cask::CLI::Uninstall.run('anvil') |
|||
}.must_output <<-OUTPUT.gsub(/^ */, '') |
|||
Error: anvil is not installed |
|||
OUTPUT |
|||
end |
|||
|
|||
it "delegates to the installer to properly uninstall" do |
|||
fake_cask = stub('fake-cask') |
|||
Cask.stubs(:load).with('fake-cask').returns(fake_cask) |
|||
Cask::Installer.expects(:uninstall).with(fake_cask) |
|||
Cask::CLI::Uninstall.run('fake-cask') |
|||
end |
|||
end |
Loading…
Reference in new issue