diff options
| author | Jack Nagel | 2013-10-25 17:29:36 -0500 | 
|---|---|---|
| committer | Jack Nagel | 2013-10-25 17:29:45 -0500 | 
| commit | 08d52978c2ca2e4ecf1dce2ac2c9a6547c6bc7f8 (patch) | |
| tree | 77f87525f2dc2ad44d69c85a84c778590977a026 /Library/Homebrew/test | |
| parent | 4e6f20272a514d594044790fda7d759d7bac07a2 (diff) | |
| download | homebrew-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.rb | 13 | 
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  | 
