Remove default values from formula constructor parameters

Closes Homebrew/homebrew#30017.
This commit is contained in:
Jack Nagel 2014-06-10 15:41:45 -05:00
parent 84cd9cc28f
commit 801cdd9045
2 changed files with 7 additions and 11 deletions

View File

@ -26,8 +26,7 @@ class Formula
attr_accessor :local_bottle_path attr_accessor :local_bottle_path
# Homebrew determines the name def initialize(name, path)
def initialize name='__UNKNOWN__', path=self.class.path(name)
@name = name @name = name
@path = path @path = path
@homepage = self.class.homepage @homepage = self.class.homepage

View File

@ -4,18 +4,15 @@ require 'test/testball'
class FormulaTests < Test::Unit::TestCase class FormulaTests < Test::Unit::TestCase
include VersionAssertions include VersionAssertions
def test_formula_path_initialization def test_formula_instantiation
name = "formula_name"
klass = Class.new(Formula) { url "http://example.com/foo-1.0.tar.gz" } klass = Class.new(Formula) { url "http://example.com/foo-1.0.tar.gz" }
name = "formula_name"
path = Formula.path(name)
f = klass.new(name) f = klass.new(name, path)
assert_equal Formula.path(name), f.path assert_equal name, f.name
f = klass.new(name, path = Object.new)
assert_equal path, f.path assert_equal path, f.path
assert_raises(ArgumentError) { klass.new }
f = klass.new(name, nil)
assert_nil f.path
end end
def test_prefix def test_prefix