From f222ca04fd31b0cd05e25b0c92b27049802147bb Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Mon, 23 Jun 2014 21:48:15 -0500 Subject: [PATCH] Remove pin directory when empty --- Library/Homebrew/formula_pin.rb | 1 + Library/Homebrew/test/test_formula_pin.rb | 14 ++++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Library/Homebrew/formula_pin.rb b/Library/Homebrew/formula_pin.rb index 969e8a4d24..842d108c2c 100644 --- a/Library/Homebrew/formula_pin.rb +++ b/Library/Homebrew/formula_pin.rb @@ -23,6 +23,7 @@ class FormulaPin def unpin path.unlink if pinned? + PINDIR.rmdir_if_possible end def pinned? diff --git a/Library/Homebrew/test/test_formula_pin.rb b/Library/Homebrew/test/test_formula_pin.rb index 9478e54eaf..6dbf3e173b 100644 --- a/Library/Homebrew/test/test_formula_pin.rb +++ b/Library/Homebrew/test/test_formula_pin.rb @@ -27,19 +27,17 @@ class FormulaPinTests < Homebrew::TestCase assert_predicate @pin, :pinnable? 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 (@f.rack+'0.1').mkpath @pin.pin + + assert_predicate @pin, :pinned? + assert_equal 1, FormulaPin::PINDIR.children.length + @pin.unpin + refute_predicate @pin, :pinned? - assert_equal 0, FormulaPin::PINDIR.children.length + refute_predicate FormulaPin::PINDIR, :directory? end def teardown