Eliminate nil check on path parameter
This commit is contained in:
parent
d31bee2e5b
commit
e3e14a0cdf
@ -30,10 +30,9 @@ class Formula
|
|||||||
attr_reader :cxxstdlib
|
attr_reader :cxxstdlib
|
||||||
|
|
||||||
# Homebrew determines the name
|
# Homebrew determines the name
|
||||||
def initialize name='__UNKNOWN__', path=nil
|
def initialize name='__UNKNOWN__', path=self.class.path(name)
|
||||||
@name = name
|
@name = name
|
||||||
# If we got an explicit path, use that, else determine from the name
|
@path = path
|
||||||
@path = path.nil? ? self.class.path(name) : path
|
|
||||||
@homepage = self.class.homepage
|
@homepage = self.class.homepage
|
||||||
|
|
||||||
set_spec :stable
|
set_spec :stable
|
||||||
|
|||||||
@ -4,6 +4,20 @@ require 'test/testball'
|
|||||||
class FormulaTests < Test::Unit::TestCase
|
class FormulaTests < Test::Unit::TestCase
|
||||||
include VersionAssertions
|
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
|
def test_prefix
|
||||||
f = TestBall.new
|
f = TestBall.new
|
||||||
assert_equal HOMEBREW_CELLAR/f.name/'0.1', f.prefix
|
assert_equal HOMEBREW_CELLAR/f.name/'0.1', f.prefix
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user