aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorJack Nagel2013-10-25 17:29:36 -0500
committerJack Nagel2013-10-25 17:29:45 -0500
commit08d52978c2ca2e4ecf1dce2ac2c9a6547c6bc7f8 (patch)
tree77f87525f2dc2ad44d69c85a84c778590977a026 /Library/Homebrew/test
parent4e6f20272a514d594044790fda7d759d7bac07a2 (diff)
downloadhomebrew-08d52978c2ca2e4ecf1dce2ac2c9a6547c6bc7f8.tar.bz2
Disallow initializing Versions with non-strings
Closes #23553.
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/test_versions.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/Library/Homebrew/test/test_versions.rb b/Library/Homebrew/test/test_versions.rb
index 927cd2bac..c4fbb86f3 100644
--- a/Library/Homebrew/test/test_versions.rb
+++ b/Library/Homebrew/test/test_versions.rb
@@ -1,6 +1,19 @@
require 'testing_env'
require 'version'
+class VersionTests < Test::Unit::TestCase
+ def test_accepts_objects_responding_to_to_str
+ value = stub(:to_str => '0.1')
+ assert_equal '0.1', Version.new(value).to_s
+ end
+
+ def test_raises_for_non_string_objects
+ assert_raises(TypeError) { Version.new(1.1) }
+ assert_raises(TypeError) { Version.new(1) }
+ assert_raises(TypeError) { Version.new(:symbol) }
+ end
+end
+
class VersionComparisonTests < Test::Unit::TestCase
include VersionAssertions