aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/formula.rb2
-rw-r--r--Library/Homebrew/test/test_formula.rb16
2 files changed, 17 insertions, 1 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index c994202e3..a6305eaaf 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -80,7 +80,7 @@ class Formula
# if the dir is there, but it's empty we consider it not installed
def installed?
- installed_prefix.children.length > 0 rescue false
+ (dir = installed_prefix).directory? && dir.children.length > 0
end
def pinable?
diff --git a/Library/Homebrew/test/test_formula.rb b/Library/Homebrew/test/test_formula.rb
index 918ff714f..bdeb398d8 100644
--- a/Library/Homebrew/test/test_formula.rb
+++ b/Library/Homebrew/test/test_formula.rb
@@ -14,6 +14,22 @@ class FormulaTests < Test::Unit::TestCase
assert_kind_of Pathname, f.prefix
end
+ def test_installed?
+ f = TestBall.new
+ f.stubs(:installed_prefix).returns(stub(:directory? => false))
+ assert !f.installed?
+
+ f.stubs(:installed_prefix).returns(
+ stub(:directory? => true, :children => [])
+ )
+ assert !f.installed?
+
+ f.stubs(:installed_prefix).returns(
+ stub(:directory? => true, :children => [stub])
+ )
+ assert f.installed?
+ end
+
def test_class_naming
assert_equal 'ShellFm', Formula.class_s('shell.fm')
assert_equal 'Fooxx', Formula.class_s('foo++')