blob: aa545f6d439c3a9ae259e7b6c31e1f0c50f77003 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
require 'testing_env'
require 'extend/ARGV' # needs to be after test/unit to avoid conflict with OptionsParser
ARGV.extend(HomebrewArgvExtension)
require 'test/testball'
require 'utils'
require 'brew.h'
class MostlyAbstractFormula <Formula
@url=''
@homepage = 'http://example.com/'
end
class TestBallOverrideBrew <Formula
def initialize
super "foo"
end
def brew
end
end
class FormulaTests < Test::Unit::TestCase
def test_prefix
nostdout do
TestBall.new.brew do |f|
assert_equal File.expand_path(f.prefix), (HOMEBREW_CELLAR+f.name+'0.1').to_s
assert_kind_of Pathname, f.prefix
end
end
end
def test_class_naming
assert_equal 'ShellFm', Formula.class_s('shell.fm')
assert_equal 'Fooxx', Formula.class_s('foo++')
assert_equal 'SLang', Formula.class_s('s-lang')
assert_equal 'PkgConfig', Formula.class_s('pkg-config')
assert_equal 'FooBar', Formula.class_s('foo_bar')
end
def test_cant_override_brew
assert_raises(RuntimeError) { TestBallOverrideBrew.new }
end
def test_abstract_formula
f=MostlyAbstractFormula.new
assert_equal '__UNKNOWN__', f.name
assert_raises(RuntimeError) { f.prefix }
nostdout { assert_raises(RuntimeError) { f.brew } }
end
end
|