aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMax Howell2009-07-31 14:04:24 +0100
committerMax Howell2009-07-31 14:04:24 +0100
commit141bc27668ed5d5249f5121f0343af36407e73f1 (patch)
tree4295c8610aa26257653b7a57ffc67a59441a927c /Library
parent325912dd42805a9fdeac22268049747230a8e097 (diff)
downloadhomebrew-141bc27668ed5d5249f5121f0343af36407e73f1.tar.bz2
Tests for Formula.*
Diffstat (limited to 'Library')
-rwxr-xr-xLibrary/Homebrew/unittest.rb32
1 files changed, 26 insertions, 6 deletions
diff --git a/Library/Homebrew/unittest.rb b/Library/Homebrew/unittest.rb
index 0da415c95..8e3fcf453 100755
--- a/Library/Homebrew/unittest.rb
+++ b/Library/Homebrew/unittest.rb
@@ -153,25 +153,30 @@ class BeerTasting <Test::Unit::TestCase
def test_install
f=TestBall.new
+
+ assert !f.installed?
+
nostdout do
f.brew do
f.install
end
end
+ assert_match Regexp.new("^#{HOMEBREW_CELLAR}/"), f.prefix.to_s
+
assert f.bin.directory?
- assert_equal f.bin.children.length, 3
+ assert_equal 3, f.bin.children.length
libexec=f.prefix+'libexec'
assert libexec.directory?
- assert_equal libexec.children.length, 1
-
+ assert_equal 1, libexec.children.length
assert !(f.prefix+'main.c').exist?
+ assert f.installed?
keg=Keg.new f
keg.ln
- assert_equal HOMEBREW_PREFIX.children.length, 1
+ assert_equal 2, HOMEBREW_PREFIX.children.length
assert (HOMEBREW_PREFIX+'bin').directory?
- assert_equal (HOMEBREW_PREFIX+'bin').children.length, 3
+ assert_equal 3, (HOMEBREW_PREFIX+'bin').children.length
end
def test_md5
@@ -183,4 +188,19 @@ class BeerTasting <Test::Unit::TestCase
nostdout { TestBallInvalidMd5.new.brew {} }
end
end
-end \ No newline at end of file
+
+ FOOBAR='foo-bar'
+ def test_formula_funcs
+ classname=Formula.class(FOOBAR)
+ path=Formula.path(FOOBAR)
+
+ assert_equal "FooBar", classname
+ assert_match Regexp.new("^#{HOMEBREW_PREFIX}/Library/Formula"), path.to_s
+
+ path=HOMEBREW_PREFIX+'Library'+'Formula'+"#{FOOBAR}.rb"
+ path.dirname.mkpath
+ `echo "require 'brewkit'; class #{classname} <Formula; @url=''; end" > #{path}`
+
+ assert_not_nil Formula.create(FOOBAR)
+ end
+end