Check existence rather than rescue exceptions
This commit is contained in:
parent
67844c9012
commit
bd4aaac96b
@ -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?
|
||||
|
||||
@ -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++')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user