Browse Source

handle multiple casks with install

should address #52

includes better error handling if a nonexistent cask is referenced

first test-driven commit, suckas!
phinze 12 years ago
parent
commit
ab564ef254
  1. 1
      Gemfile
  2. 4
      Gemfile.lock
  3. 2
      Rakefile
  4. 13
      lib/cask/cli/install.rb
  5. 20
      test/cli/install_test.rb

1
Gemfile

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

4
Gemfile.lock

@ -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

@ -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

13
lib/cask/cli/install.rb

@ -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

@ -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…
Cancel
Save