Browse Source

allow test suite to be run without internet

phinze 12 years ago
parent
commit
ef25273d96
  1. 7
      test/cask/actions_test.rb
  2. 2
      test/cask/dsl_test.rb
  3. 8
      test/cask/installer_test.rb
  4. 2
      test/cask/scopes_test.rb
  5. 6
      test/support/Casks/local-caffeine.rb
  6. BIN
      test/support/binaries/caffeine.zip
  7. 23
      test/test_helper.rb

7
test/cask/actions_test.rb

@ -8,15 +8,14 @@ describe Cask::Actions do
fake_appdir.mkpath
Cask.stubs(:appdir).returns(fake_appdir)
@caffeine = Cask.load('caffeine')
@caffeine = Cask.load('local-caffeine')
shutup { Cask::Installer.install(@caffeine) }
@appdir = HOMEBREW_CELLAR/'caffeine'/@caffeine.version
@appdir = HOMEBREW_CELLAR/'local-caffeine'/@caffeine.version
@app = @appdir/'Caffeine.app'
end
after do
ARGV.replace ['caffeine']
shutup { Homebrew.uninstall }
Cask::Installer.uninstall(@caffeine)
end
it "works with an applistion in the root directory" do

2
test/cask/dsl_test.rb

@ -2,7 +2,7 @@ require 'test_helper'
describe Cask::DSL do
it "lets you set url, homepage, and version" do
test_cask = TestCask.new
test_cask = Cask.load('test-cask')
test_cask.url.must_equal URI('http://example.com/TestCask.dmg')
test_cask.homepage.must_equal 'http://example.com/'
test_cask.version.must_equal '1.2.3'

8
test/cask/installer_test.rb

@ -3,13 +3,13 @@ require 'test_helper'
describe Cask::Installer do
describe "install" do
it "downloads and installs a nice fresh Cask" do
caffeine = Cask.load('caffeine')
caffeine = Cask.load('local-caffeine')
shutup do
Cask::Installer.install(caffeine)
end
dest_path = HOMEBREW_CELLAR/'caffeine'/caffeine.version
dest_path = HOMEBREW_CELLAR/'local-caffeine'/caffeine.version
dest_path.must_be :directory?
application = dest_path/'Caffeine.app'
application.must_be :directory?
@ -18,14 +18,14 @@ describe Cask::Installer do
describe "uninstall" do
it "fully uninstalls a cask" do
caffeine = Cask.load('caffeine')
caffeine = Cask.load('local-caffeine')
shutup do
Cask::Installer.install(caffeine)
Cask::Installer.uninstall(caffeine)
end
dest_path = HOMEBREW_CELLAR/'caffeine'/caffeine.version
dest_path = HOMEBREW_CELLAR/'local-caffeine'/caffeine.version
application = dest_path/'Caffeine.app'
application.wont_be :directory?

2
test/cask/scopes_test.rb

@ -3,7 +3,7 @@ require 'test_helper'
describe Cask::Scopes do
describe 'installed' do
it "returns a list of strings" do
caffeine = Cask.load('caffeine')
caffeine = Cask.load('local-caffeine')
shutup do
Cask::Installer.install(caffeine)

6
test/support/Casks/local-caffeine.rb

@ -0,0 +1,6 @@
class LocalCaffeine < Cask
url TestHelper.local_binary('caffeine.zip')
homepage 'http://example.com/local-caffeine'
version '1.2.3'
end

BIN
test/support/binaries/caffeine.zip

Binary file not shown.

23
test/test_helper.rb

@ -33,11 +33,22 @@ require 'mocha'
# our baby
require 'cask'
# "install" brew-cask into homebrew testing env
require 'cmd/tap'
shutup do
Homebrew.install_tap 'phinze', 'cask'
class TestHelper
# helper for test casks to reference local files easily
def self.local_binary(name)
path = File.join(File.dirname(__FILE__), 'support', 'binaries', name)
"file://#{path}"
end
end
# a test cask
require 'support/Casks/test-cask'
# pretend like we installed the cask tap
project_root = Pathname.new(File.expand_path("#{File.dirname(__FILE__)}/../"))
taps_dest = HOMEBREW_LIBRARY/"Taps"
taps_dest.mkdir
FileUtils.ln_s project_root, taps_dest/"phinze-cask"
# also jack in some test casks
FileUtils.ln_s project_root/'test'/'support', taps_dest/"phinze-testcasks"

Loading…
Cancel
Save