forked from Homebrew/homebrew-cask
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
thanks to @passcod for original implementation on his fork refs Homebrew#72
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module Cask::CLI::Open | ||
def self.run(*cask_names) | ||
cask_names.each do |cask_name| | ||
begin | ||
cask = Cask.load(cask_name) | ||
system "open", cask.homepage | ||
rescue CaskUnavailableError => e | ||
onoe e | ||
end | ||
end | ||
end | ||
|
||
def self.help | ||
"opens the homepage of the cask of the given name" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require 'test_helper' | ||
|
||
module RecordSystemCalls | ||
def system(*command) | ||
system_commands << command | ||
end | ||
|
||
def reset! | ||
@system_commands = [] | ||
end | ||
|
||
def system_commands | ||
@system_commands ||= [] | ||
end | ||
end | ||
|
||
module Cask::CLI::Open | ||
extend RecordSystemCalls | ||
end | ||
|
||
describe Cask::CLI::Open do | ||
before do | ||
Cask::CLI::Open.reset! | ||
end | ||
|
||
it 'opens the homepage for the specified cask' do | ||
Cask::CLI::Open.run('alfred') | ||
Cask::CLI::Open.system_commands.must_equal [ | ||
['open', 'http://www.alfredapp.com/'] | ||
] | ||
end | ||
|
||
it 'works for multiple casks' do | ||
Cask::CLI::Open.run('alfred', 'adium') | ||
Cask::CLI::Open.system_commands.must_equal [ | ||
['open', 'http://www.alfredapp.com/'], | ||
['open', 'http://www.adium.im/'] | ||
] | ||
end | ||
end | ||
|