Don't attempt to detect version if URL is not set

This commit is contained in:
Jack Nagel 2014-12-31 10:37:29 -05:00
parent 8ebaa9c0a9
commit 62c0a391b4
2 changed files with 6 additions and 0 deletions

View File

@ -148,6 +148,8 @@ class Resource
private private
def detect_version(val) def detect_version(val)
return if val.nil? && url.nil?
case val case val
when nil then Version.detect(url, specs) when nil then Version.detect(url, specs)
when String then Version.new(val) when String then Version.new(val)

View File

@ -81,6 +81,10 @@ class ResourceTests < Homebrew::TestCase
assert_raises(TypeError) { @resource.version(Object.new) } assert_raises(TypeError) { @resource.version(Object.new) }
end end
def test_version_when_url_is_not_set
assert_nil @resource.version
end
def test_mirrors def test_mirrors
assert_empty @resource.mirrors assert_empty @resource.mirrors
@resource.mirror('foo') @resource.mirror('foo')