diff --git a/lib/cask.rb b/lib/cask.rb index 41e1e600e..3c1fcf341 100644 --- a/lib/cask.rb +++ b/lib/cask.rb @@ -32,12 +32,12 @@ class Cask end def self.appdir - Pathname.new(File.expand_path("~/Applications")) + @appdir ||= Pathname.new(File.expand_path("~/Applications")) end def self.init - HOMEBREW_CACHE.mkpath unless HOMEBREW_CACHE.exists? - appdir.mkpath unless appdir.exists? + HOMEBREW_CACHE.mkpath unless HOMEBREW_CACHE.exist? + appdir.mkpath unless appdir.exist? end def self.path(cask_title) diff --git a/test/cask_test.rb b/test/cask_test.rb index 3a5f6ba9b..57d171894 100644 --- a/test/cask_test.rb +++ b/test/cask_test.rb @@ -37,4 +37,14 @@ describe Cask do application.must_be :directory? end end + + describe "init" do + it "sets up dependent directories required for us to properly function" do + HOMEBREW_CACHE.stubs(:exist?).returns(false) + Cask.appdir.stubs(:exist?).returns(false) + HOMEBREW_CACHE.expects :mkpath + Cask.appdir.expects :mkpath + Cask.init + end + end end