diff options
| -rw-r--r-- | Library/Homebrew/formula.rb | 5 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_formula.rb | 14 | 
2 files changed, 16 insertions, 3 deletions
| diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 38e8d8f1f..d70b59a9c 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -30,10 +30,9 @@ class Formula    attr_reader :cxxstdlib    # Homebrew determines the name -  def initialize name='__UNKNOWN__', path=nil +  def initialize name='__UNKNOWN__', path=self.class.path(name)      @name = name -    # If we got an explicit path, use that, else determine from the name -    @path = path.nil? ? self.class.path(name) : path +    @path = path      @homepage = self.class.homepage      set_spec :stable diff --git a/Library/Homebrew/test/test_formula.rb b/Library/Homebrew/test/test_formula.rb index 51b6d8813..dd4f9a3e3 100644 --- a/Library/Homebrew/test/test_formula.rb +++ b/Library/Homebrew/test/test_formula.rb @@ -4,6 +4,20 @@ require 'test/testball'  class FormulaTests < Test::Unit::TestCase    include VersionAssertions +  def test_formula_path_initialization +    name = "formula_name" +    klass = Class.new(Formula) { url "http://example.com/foo-1.0.tar.gz" } + +    f = klass.new(name) +    assert_equal Formula.path(name), f.path + +    f = klass.new(name, path = Object.new) +    assert_equal path, f.path + +    f = klass.new(name, nil) +    assert_nil f.path +  end +    def test_prefix      f = TestBall.new      assert_equal HOMEBREW_CELLAR/f.name/'0.1', f.prefix | 
