Remove pin directory when empty

This commit is contained in:
Jack Nagel 2014-06-23 21:48:15 -05:00
parent 35b9a00706
commit f222ca04fd
2 changed files with 7 additions and 8 deletions

View File

@ -23,6 +23,7 @@ class FormulaPin
def unpin def unpin
path.unlink if pinned? path.unlink if pinned?
PINDIR.rmdir_if_possible
end end
def pinned? def pinned?

View File

@ -27,19 +27,17 @@ class FormulaPinTests < Homebrew::TestCase
assert_predicate @pin, :pinnable? assert_predicate @pin, :pinnable?
end end
def test_pin
(@f.rack+'0.1').mkpath
@pin.pin
assert_predicate @pin, :pinned?
assert_equal 1, FormulaPin::PINDIR.children.length
end
def test_unpin def test_unpin
(@f.rack+'0.1').mkpath (@f.rack+'0.1').mkpath
@pin.pin @pin.pin
assert_predicate @pin, :pinned?
assert_equal 1, FormulaPin::PINDIR.children.length
@pin.unpin @pin.unpin
refute_predicate @pin, :pinned? refute_predicate @pin, :pinned?
assert_equal 0, FormulaPin::PINDIR.children.length refute_predicate FormulaPin::PINDIR, :directory?
end end
def teardown def teardown