phinze
12 years ago
18 changed files with 170 additions and 100 deletions
@ -0,0 +1,5 @@ |
|||
class Cask::Fetcher |
|||
def self.head(url) |
|||
`curl --max-time 5 --silent --location --head '#{url}'` |
|||
end |
|||
end |
@ -1,21 +1,33 @@ |
|||
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') |
|||
it "only links casks mentioned when arguments are provided" do |
|||
caffeine = Cask.load('local-caffeine') |
|||
transmission = Cask.load('local-transmission') |
|||
|
|||
shutup do |
|||
Cask::Installer.install caffeine |
|||
Cask::Installer.install transmission |
|||
|
|||
Cask::CLI::Linkapps.run('local-transmission') |
|||
end |
|||
|
|||
(Cask.appdir/"Transmission.app").must_be :symlink? |
|||
(Cask.appdir/"Caffeine.app").wont_be :symlink? |
|||
end |
|||
|
|||
it "links all installed casks when no arguments supplied" do |
|||
mock_cask = mock() |
|||
mock_cask.expects(:linkapps).times(3) |
|||
Cask.expects(:load).times(3).returns(mock_cask) |
|||
caffeine = Cask.load('local-caffeine') |
|||
transmission = Cask.load('local-transmission') |
|||
|
|||
shutup do |
|||
Cask::Installer.install caffeine |
|||
Cask::Installer.install transmission |
|||
|
|||
Cask.expects(:installed).returns(['mock1', 'mock2', 'mock3']) |
|||
Cask::CLI::Linkapps.run |
|||
end |
|||
|
|||
Cask::CLI::Linkapps.run |
|||
(Cask.appdir/"Transmission.app").must_be :symlink? |
|||
(Cask.appdir/"Caffeine.app").must_be :symlink? |
|||
end |
|||
end |
|||
|
@ -0,0 +1,19 @@ |
|||
# wire in a fake appdir for linkapps |
|||
CANNED_APPDIR = (HOMEBREW_REPOSITORY/"Applications") |
|||
Cask.set_appdir(CANNED_APPDIR) |
|||
|
|||
module FakeAppdirHooks |
|||
def before_setup |
|||
super |
|||
CANNED_APPDIR.mkdir |
|||
end |
|||
|
|||
def after_teardown |
|||
super |
|||
FileUtils.rm_rf(CANNED_APPDIR) |
|||
end |
|||
end |
|||
|
|||
class MiniTest::Spec |
|||
include FakeAppdirHooks |
|||
end |
@ -0,0 +1,37 @@ |
|||
class Cask::FakeFetcher |
|||
def self.fake_response_for(url, response) |
|||
@responses[url] = response |
|||
end |
|||
|
|||
def self.head(url) |
|||
@responses ||= {} |
|||
unless @responses.key?(url) |
|||
fail("no response faked for #{url.inspect}") |
|||
end |
|||
@responses[url] |
|||
end |
|||
|
|||
def self.init |
|||
@responses = {} |
|||
end |
|||
|
|||
def self.clear |
|||
@responses = {} |
|||
end |
|||
end |
|||
|
|||
module FakeFetcherHooks |
|||
def before_setup |
|||
super |
|||
Cask::FakeFetcher.init |
|||
end |
|||
|
|||
def after_teardown |
|||
super |
|||
Cask::FakeFetcher.clear |
|||
end |
|||
end |
|||
|
|||
class MiniTest::Spec |
|||
include FakeFetcherHooks |
|||
end |
Loading…
Reference in new issue