handle multiple casks with install

should address #52

includes better error handling if a nonexistent cask is referenced

first test-driven commit, suckas!
This commit is contained in:
phinze 2012-10-13 15:28:59 -05:00
parent cd70474aa9
commit ab564ef254
5 changed files with 35 additions and 5 deletions

View File

@ -2,4 +2,5 @@ source :rubygems
group :test do
gem 'purdytest'
gem 'mocha'
end

View File

@ -1,7 +1,10 @@
GEM
remote: http://rubygems.org/
specs:
metaclass (0.0.1)
minitest (2.12.1)
mocha (0.12.7)
metaclass (~> 0.0.1)
purdytest (1.0.0)
minitest (~> 2.2)
@ -9,4 +12,5 @@ PLATFORMS
ruby
DEPENDENCIES
mocha
purdytest

View File

@ -1,7 +1,7 @@
require 'rake/testtask'
Rake::TestTask.new do |t|
t.pattern = "test/*_test.rb"
t.pattern = "test/**/*_test.rb"
t.libs << 'test'
end

View File

@ -1,8 +1,13 @@
class Cask::CLI::Install
def self.run(*arguments)
cask_name, *rest = *arguments
cask = Cask.load(cask_name)
cask.install
def self.run(*cask_names)
cask_names.each do |cask_name|
cask = begin
Cask.load(cask_name)
rescue CaskUnavailableError => e
onoe e
end
cask.install if cask
end
end
def self.help

20
test/cli/install_test.rb Normal file
View File

@ -0,0 +1,20 @@
require 'test_helper'
describe Cask::CLI::Install do
it "allows install of multiple casks at once" do
stub_cask = stub(:install => nil)
Cask.expects(:load).with('adium').returns(stub_cask)
Cask.expects(:load).with('google-chrome').returns(stub_cask)
Cask::CLI::Install.run('adium', 'google-chrome')
end
it "properly handles casks that are not present" do
stub_cask = stub(:install => nil)
Cask.expects(:load).with('adium').returns(stub_cask)
Cask.expects(:load).with('what-the-balls').raises(CaskUnavailableError.new('what-the-balls'))
Cask.expects(:load).with('google-chrome').returns(stub_cask)
shutup do
Cask::CLI::Install.run('adium', 'what-the-balls', 'google-chrome')
end
end
end