diff options
Diffstat (limited to 'Library/Homebrew/unittest.rb')
| -rwxr-xr-x | Library/Homebrew/unittest.rb | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/Library/Homebrew/unittest.rb b/Library/Homebrew/unittest.rb index 08a95e1f3..d619b9601 100755 --- a/Library/Homebrew/unittest.rb +++ b/Library/Homebrew/unittest.rb @@ -1,65 +1,80 @@ #!/usr/bin/ruby -$:.unshift File.dirname __FILE__ +$:.unshift File.dirname(__FILE__) require 'test/unit' require 'brewkit' class TestFormula <Formula - def initialize url, md5 + def initialize url, md5='nomd5' @url=url @md5=md5 - @name='test' - super() + super 'test' end end class BeerTasting <Test::Unit::TestCase def test_version_all_dots - r=TestFormula.new "http://example.com/foo.bar.la.1.14.zip", 'nomd5' + r=TestFormula.new "http://example.com/foo.bar.la.1.14.zip" assert_equal '1.14', r.version end def test_version_underscore_separator - r=TestFormula.new "http://example.com/grc_1.1.tar.gz", 'nomd5' + r=TestFormula.new "http://example.com/grc_1.1.tar.gz" assert_equal '1.1', r.version end - def test_version_underscores_all_the_way - r=TestFormula.new "http://example.com/boost_1_39_0.tar.bz2", 'nomd5' + def test_boost_version_style + r=TestFormula.new "http://example.com/boost_1_39_0.tar.bz2" assert_equal '1.39.0', r.version end + def test_erlang_version_style + r=TestFormula.new "http://erlang.org/download/otp_src_R13B.tar.gz" + assert_equal 'R13B', r.version + end + def test_version_internal_dash - r=TestFormula.new "http://example.com/foo-arse-1.1-2.tar.gz", 'nomd5' + r=TestFormula.new "http://example.com/foo-arse-1.1-2.tar.gz" assert_equal '1.1-2', r.version end def test_version_single_digit - r=TestFormula.new "http://example.com/foo_bar.45.tar.gz", 'nomd5' + r=TestFormula.new "http://example.com/foo_bar.45.tar.gz" assert_equal '45', r.version end def test_noseparator_single_digit - r=TestFormula.new "http://example.com/foo_bar45.tar.gz", 'nomd5' + r=TestFormula.new "http://example.com/foo_bar45.tar.gz" assert_equal '45', r.version end def test_version_developer_that_hates_us_format - r=TestFormula.new "http://example.com/foo-bar-la.1.2.3.tar.gz", 'nomd5' + r=TestFormula.new "http://example.com/foo-bar-la.1.2.3.tar.gz" assert_equal '1.2.3', r.version end def test_version_regular - r=TestFormula.new "http://example.com/foo_bar-1.21.tar.gz", 'nomd5' + r=TestFormula.new "http://example.com/foo_bar-1.21.tar.gz" assert_equal '1.21', r.version end def test_yet_another_version - r=TestFormula.new "http://example.com/mad-0.15.1b.tar.gz", 'nomd5' + r=TestFormula.new "http://example.com/mad-0.15.1b.tar.gz" assert_equal '0.15.1b', r.version end + def test_supported_compressed_types + assert_nothing_raised do + TestFormula.new 'test-0.1.tar.gz' + TestFormula.new 'test-0.1.tar.bz2' + TestFormula.new 'test-0.1.tgz' + TestFormula.new 'test-0.1.zip' + end + assert_raise(RuntimeError) {TestFormula.new 'test-0.1.7'} + assert_raise(RuntimeError) {TestFormula.new 'test-0.1.arse'} + end + def test_prefix url='http://www.methylblue.com/test-0.1.tar.gz' md5='d496ea538a21dc4bb8524a8888baf88c' |
