blob: ff50c86d1277cc0d53444785e2e81f67a4c30399 (
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
require "formula"
describe Formula do
describe "::new" do
matcher :fail_with_invalid do |attr|
match do |actual|
expect {
begin
actual.call
rescue => e
expect(e.attr).to eq(attr)
raise e
end
}.to raise_error(FormulaValidationError)
end
def supports_block_expectations?
true
end
end
it "cant override the `brew` method" do
expect {
formula do
def brew; end
end
}.to raise_error(RuntimeError, /You cannot override Formula#brew/)
end
it "validates the `name`" do
expect {
formula "name with spaces" do
url "foo"
version "1.0"
end
}.to fail_with_invalid :name
end
it "validates the `url`" do
expect {
formula do
url ""
version "1"
end
}.to fail_with_invalid :url
end
it "validates the `version`" do
expect {
formula do
url "foo"
version "version with spaces"
end
}.to fail_with_invalid :version
expect {
formula do
url "foo"
version ""
end
}.to fail_with_invalid :version
expect {
formula do
url "foo"
version nil
end
}.to fail_with_invalid :version
end
specify "devel-only is valid" do
f = formula do
devel do
url "foo"
version "1.0"
end
end
expect(f).to be_devel
end
specify "head-only is valid" do
f = formula do
head "foo"
end
expect(f).to be_head
end
it "fails when Formula is empty" do
expect { formula {} }.to raise_error(FormulaSpecificationError)
end
end
end
|