diff --git a/test/cask/actions_test.rb b/test/cask/actions_test.rb index de74656d7..466ed1059 100644 --- a/test/cask/actions_test.rb +++ b/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 diff --git a/test/cask/dsl_test.rb b/test/cask/dsl_test.rb index 3d360472c..d39fd224b 100644 --- a/test/cask/dsl_test.rb +++ b/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' diff --git a/test/cask/installer_test.rb b/test/cask/installer_test.rb index 32b141966..2b98487b4 100644 --- a/test/cask/installer_test.rb +++ b/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? diff --git a/test/cask/scopes_test.rb b/test/cask/scopes_test.rb index 26d523e2d..16e9f43e1 100644 --- a/test/cask/scopes_test.rb +++ b/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) diff --git a/test/support/Casks/local-caffeine.rb b/test/support/Casks/local-caffeine.rb new file mode 100644 index 000000000..eb59fa22e --- /dev/null +++ b/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 + diff --git a/test/support/binaries/caffeine.zip b/test/support/binaries/caffeine.zip new file mode 100644 index 000000000..74aca21db Binary files /dev/null and b/test/support/binaries/caffeine.zip differ diff --git a/test/test_helper.rb b/test/test_helper.rb index c706e6676..30a408fcc 100644 --- a/test/test_helper.rb +++ b/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"