forked from Homebrew/homebrew-cask
-
Notifications
You must be signed in to change notification settings - Fork 0
/
depends_on_test.rb
122 lines (107 loc) · 3.36 KB
/
depends_on_test.rb
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
require 'test_helper'
# todo: this test should be named after the corresponding class, once
# that class is abstracted from installer.rb
describe "Satisfy Dependencies and Requirements" do
# todo: test that depends_on :formula invokes Homebrew
#
# describe "depends_on :formula" do
# it "" do
# end
# end
#
describe "depends_on :cask" do
it "raises an exception when depends_on :cask is cyclic" do
dep_cask = Hbc.load('with-depends-on-cask-cyclic')
lambda {
shutup do
Hbc::Installer.new(dep_cask).install
end
}.must_raise(Hbc::CaskCyclicCaskDependencyError)
end
it "installs the dependency of a Cask and the Cask itself" do
csk = Hbc.load('with-depends-on-cask')
dependency = Hbc.load(csk.depends_on.cask.first)
shutup do
Hbc::Installer.new(csk).install
end
csk.must_be :installed?
dependency.must_be :installed?
end
end
describe "depends_on :macos" do
it "understands depends_on :macos => <array>" do
macos_cask = Hbc.load('with-depends-on-macos-array')
shutup do
Hbc::Installer.new(macos_cask).install
end
end
it "understands depends_on :macos => <comparison>" do
macos_cask = Hbc.load('with-depends-on-macos-comparison')
shutup do
Hbc::Installer.new(macos_cask).install
end
end
it "understands depends_on :macos => <string>" do
macos_cask = Hbc.load('with-depends-on-macos-string')
shutup do
Hbc::Installer.new(macos_cask).install
end
end
it "understands depends_on :macos => <symbol>" do
macos_cask = Hbc.load('with-depends-on-macos-symbol')
shutup do
Hbc::Installer.new(macos_cask).install
end
end
it "raises an exception when depends_on :macos is not satisfied" do
macos_cask = Hbc.load('with-depends-on-macos-failure')
lambda {
shutup do
Hbc::Installer.new(macos_cask).install
end
}.must_raise(Hbc::CaskError)
end
end
describe "depends_on :arch" do
it "succeeds when depends_on :arch is satisfied" do
arch_cask = Hbc.load('with-depends-on-arch')
shutup do
Hbc::Installer.new(arch_cask).install
end
end
it "raises an exception when depends_on :arch is not satisfied" do
arch_cask = Hbc.load('with-depends-on-arch-failure')
lambda {
shutup do
Hbc::Installer.new(arch_cask).install
end
}.must_raise(Hbc::CaskError)
end
end
describe "depends_on :x11" do
it "succeeds when depends_on :x11 is satisfied" do
x11_cask = Hbc.load('with-depends-on-x11')
shutup do
Hbc::Installer.new(x11_cask).install
end
end
it "raises an exception when depends_on :x11 is not satisfied" do
x11_cask = Hbc.load('with-depends-on-x11')
Hbc.stubs(:x11_libpng).returns([Pathname.new('/usr/path/does/not/exist')])
lambda {
shutup do
Hbc::Installer.new(x11_cask).install
end
}.must_raise(Hbc::CaskX11DependencyError)
end
it "never raises when depends_on :x11 => false" do
x11_cask = Hbc.load('with-depends-on-x11-false')
Hbc.stubs(:x11_executable).returns(Pathname.new('/usr/path/does/not/exist'))
lambda {
shutup do
Hbc::Installer.new(x11_cask).install
end
} # won't raise
end
end
end