Browse Source

demockify actions_tests

phinze 12 years ago
parent
commit
97b715b27d
  1. 6
      lib/cask/actions.rb
  2. 10
      test/cask/actions_test.rb
  3. 4
      test/support/fake_appdir.rb
  4. 4
      test/test_helper.rb

6
lib/cask/actions.rb

@ -5,13 +5,13 @@ module Cask::Actions
target = destination_path.join(app)
if destination.symlink?
# destination exists but is symlink; removing and relinking
puts "[#{self}] linking #{File.basename(destination)}"
ohai "[#{self}] linking #{File.basename(destination)}"
destination.delete
destination.make_symlink(target)
elsif destination.directory? || destination.file?
puts "[#{self}] NOT linking #{File.basename(destination)} - already exists"
ohai "[#{self}] NOT linking #{File.basename(destination)} - already exists"
else
puts "[#{self}] linking #{File.basename(destination)}"
ohai "[#{self}] linking #{File.basename(destination)}"
destination.make_symlink(target)
end
end

10
test/cask/actions_test.rb

@ -1,17 +1,11 @@
require 'test_helper'
require 'cmd/uninstall'
describe Cask::Actions do
describe 'linkapps' do
before do
fake_appdir = HOMEBREW_PREFIX/"Applications"
fake_appdir.mkpath
Cask.stubs(:appdir).returns(fake_appdir)
@caffeine = Cask.load('local-caffeine')
shutup { Cask::Installer.install(@caffeine) }
@appdir = HOMEBREW_CELLAR/'local-caffeine'/@caffeine.version
@app = @appdir/'Caffeine.app'
@app = @caffeine.destination_path/'Caffeine.app'
end
after do
@ -30,7 +24,7 @@ describe Cask::Actions do
end
it "works with an application in a subdir" do
appsubdir = @appdir/'subdir'
appsubdir = @caffeine.destination_path/'subdir'
appsubdir.mkpath
FileUtils.mv @app, appsubdir
appinsubdir = appsubdir/'Caffeine.app'

4
test/support/fake_appdir.rb

@ -10,10 +10,10 @@ module FakeAppdirHooks
def after_teardown
super
CANNED_APPDIR.rm_rf
FileUtils.rm_rf(CANNED_APPDIR)
end
end
class MiniTest::Spec
include FakeFetcherHooks
include FakeAppdirHooks
end

4
test/test_helper.rb

@ -52,10 +52,6 @@ end
require 'support/fake_fetcher'
require 'support/fake_appdir'
# wire in a fake linkapps destination
canned_appdir = (HOMEBREW_REPOSITORY/"Applications").tap(&:mkdir)
Cask.set_appdir(canned_appdir)
# pretend like we installed the cask tap
project_root = Pathname.new(File.expand_path("#{File.dirname(__FILE__)}/../"))
taps_dest = HOMEBREW_LIBRARY/"Taps"

Loading…
Cancel
Save