Don't return a version that equals the basename

Return nil instead
This commit is contained in:
Max Howell 2009-08-22 15:53:35 +01:00
parent c532d11e7a
commit f9d7b34945
2 changed files with 8 additions and 1 deletions

View File

@ -128,6 +128,8 @@ class Pathname
stem.scan /_([^_]+)/ do |match| stem.scan /_([^_]+)/ do |match|
return match.first if /\d/.match $1 return match.first if /\d/.match $1
end end
nil
end end
end end

View File

@ -196,6 +196,11 @@ class BeerTasting <Test::Unit::TestCase
end end
end end
def test_no_version
assert_nil Pathname.new("http://example.com/blah.tar").version
assert_nil Pathname.new("arse").version
end
def test_bad_version def test_bad_version
assert_raises(RuntimeError) {f=TestBadVersion.new} assert_raises(RuntimeError) {f=TestBadVersion.new}
end end