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) target = destination_path.join(app)
if destination.symlink? if destination.symlink?
# destination exists but is symlink; removing and relinking # destination exists but is symlink; removing and relinking
puts "[#{self}] linking #{File.basename(destination)}" ohai "[#{self}] linking #{File.basename(destination)}"
destination.delete destination.delete
destination.make_symlink(target) destination.make_symlink(target)
elsif destination.directory? || destination.file? elsif destination.directory? || destination.file?
puts "[#{self}] NOT linking #{File.basename(destination)} - already exists" ohai "[#{self}] NOT linking #{File.basename(destination)} - already exists"
else else
puts "[#{self}] linking #{File.basename(destination)}" ohai "[#{self}] linking #{File.basename(destination)}"
destination.make_symlink(target) destination.make_symlink(target)
end end
end end

10
test/cask/actions_test.rb

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

4
test/support/fake_appdir.rb

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

4
test/test_helper.rb

@ -52,10 +52,6 @@ end
require 'support/fake_fetcher' require 'support/fake_fetcher'
require 'support/fake_appdir' 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 # pretend like we installed the cask tap
project_root = Pathname.new(File.expand_path("#{File.dirname(__FILE__)}/../")) project_root = Pathname.new(File.expand_path("#{File.dirname(__FILE__)}/../"))
taps_dest = HOMEBREW_LIBRARY/"Taps" taps_dest = HOMEBREW_LIBRARY/"Taps"

Loading…
Cancel
Save