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:
parent
cd70474aa9
commit
ab564ef254
|
@ -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
|
||||
|
|
2
Rakefile
2
Rakefile
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue