Browse Source

allow `brew cask linkapps` to accept arguments

arguments scope linkapps command to just those casks

also added unit tests around the CLI code - whee!
phinze 12 years ago
parent
commit
9b2f2c7ecd
  1. 5
      lib/cask/cli/linkapps.rb
  2. 24
      test/cli/linkapps_test.rb

5
lib/cask/cli/linkapps.rb

@ -1,8 +1,9 @@
class Cask::CLI::Linkapps
def self.run(*arguments)
Cask.installed.map { |app|
casks_to_link = arguments.empty? ? Cask.installed : arguments
casks_to_link.each do |app|
Cask.load(app).linkapps
}
end
end
def self.help

24
test/cli/linkapps_test.rb

@ -0,0 +1,24 @@
require 'test_helper'
describe Cask::CLI::Linkapps do
it "only links casks provided in arguments" do
mock_cask = mock()
mock_cask.expects(:linkapps).twice
Cask.expects(:load).with('adium').returns(mock_cask)
Cask.expects(:load).with('google-chrome').returns(mock_cask)
Cask::CLI::Linkapps.run('adium', 'google-chrome')
end
it "links all installed casks when no arguments supplied" do
mock_cask = mock()
mock_cask.expects(:linkapps).times(3)
Cask.expects(:installed).returns(['foo', 'bar', 'baz'])
Cask.expects(:load).with('foo').returns(mock_cask)
Cask.expects(:load).with('bar').returns(mock_cask)
Cask.expects(:load).with('baz').returns(mock_cask)
Cask::CLI::Linkapps.run
end
end
Loading…
Cancel
Save