More tests for Formula and Keg

This commit is contained in:
Max Howell committed 2009-07-31 14:21:27 +01:00
1 parent 39fa1f0aee
commit f6e5874ff7
2 files changed
+23 -6

No files matched your search

+6 -6
View File
@@ -190,10 +190,6 @@ private
end
return tgz
end
def method_added method
raise 'You cannot override Formula.brew' if method == 'brew'
end
end
# somewhat useful, it'll raise if you call prefix, but it'll unpack a tar/zip
@@ -232,7 +228,7 @@ class Formula <UnidentifiedFormula
super name
@version=Pathname.new(@url).version unless @version
end
def self.class name
#remove invalid characters and camelcase
name.capitalize.gsub(/[-_\s]([a-zA-Z0-9])/) { $1.upcase }
@@ -241,13 +237,17 @@ class Formula <UnidentifiedFormula
def self.path name
Pathname.new(HOMEBREW_PREFIX)+'Library'+'Formula'+(name.downcase+'.rb')
end
def self.create name
require Formula.path(name)
return eval(Formula.class(name)).new(name)
rescue LoadError
raise "No formula for #{name}"
end
def method_added method
raise 'You cannot override Formula.brew' if method == 'brew'
end
end
# see ack.rb for an example usage
+17
View File
@@ -47,6 +47,15 @@ class TestBallInvalidMd5 <TestBall
@md5='61aa838a9e4050d1876a295a9e62cbe6'
end
class TestBallOverrideBrew <Formula
def initialize
super "foo"
end
def brew
puts "We can't override brew"
end
end
def nostdout
tmp=$stdout
@@ -177,6 +186,10 @@ class BeerTasting <Test::Unit::TestCase
assert_equal 2, HOMEBREW_PREFIX.children.length
assert (HOMEBREW_PREFIX+'bin').directory?
assert_equal 3, (HOMEBREW_PREFIX+'bin').children.length
keg.rm
assert !keg.path.exist?
assert !f.installed?
end
def test_md5
@@ -203,4 +216,8 @@ class BeerTasting <Test::Unit::TestCase
assert_not_nil Formula.create(FOOBAR)
end
def test_cant_override_brew
assert_raises(RuntimeError) { TestBallOverrideBrew.new }
end
end