aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2013-06-28 21:17:12 -0500
committerJack Nagel2013-06-28 21:18:04 -0500
commitce6763a4c56c56facf29eefb9b29506c588eb133 (patch)
tree72edcb7274c1f087f257029be04217e94e92abee /Library
parenta16c80add0f350501b3c9d4c0cf12c0010263178 (diff)
downloadhomebrew-ce6763a4c56c56facf29eefb9b29506c588eb133.tar.bz2
Reject versions that aren't strings
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/formula_support.rb2
-rw-r--r--Library/Homebrew/test/test_software_spec.rb6
2 files changed, 8 insertions, 0 deletions
diff --git a/Library/Homebrew/formula_support.rb b/Library/Homebrew/formula_support.rb
index 1ef4d3abc..69420ff0f 100644
--- a/Library/Homebrew/formula_support.rb
+++ b/Library/Homebrew/formula_support.rb
@@ -40,6 +40,8 @@ class SoftwareSpec
when nil then Version.detect(url, specs)
when String then Version.new(val)
when Hash then Version.new_with_scheme(*val.shift)
+ else
+ raise TypeError, "version '#{val.inspect}' should be a string"
end
end
diff --git a/Library/Homebrew/test/test_software_spec.rb b/Library/Homebrew/test/test_software_spec.rb
index f3eed4769..856bea611 100644
--- a/Library/Homebrew/test/test_software_spec.rb
+++ b/Library/Homebrew/test/test_software_spec.rb
@@ -66,6 +66,12 @@ class SoftwareSpecTests < Test::Unit::TestCase
assert @spec.version.detected_from_url?
end
+ def test_rejects_non_string_versions
+ assert_raises(TypeError) { @spec.version(1) }
+ assert_raises(TypeError) { @spec.version(2.0) }
+ assert_raises(TypeError) { @spec.version(Object.new) }
+ end
+
def test_mirrors
assert_empty @spec.mirrors
@spec.mirror('foo')