sprinkle 0.7.4 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +18 -14
- data/Gemfile.lock +11 -11
- data/lib/sprinkle.rb +19 -9
- data/lib/sprinkle/actors/capistrano.rb +2 -1
- data/lib/sprinkle/actors/dummy.rb +3 -3
- data/lib/sprinkle/actors/local.rb +7 -9
- data/lib/sprinkle/actors/ssh.rb +5 -5
- data/lib/sprinkle/deployment.rb +2 -1
- data/lib/sprinkle/extensions/sudo.rb +8 -4
- data/lib/sprinkle/installers/installer.rb +48 -37
- data/lib/sprinkle/installers/npm.rb +31 -30
- data/lib/sprinkle/installers/source.rb +6 -6
- data/lib/sprinkle/installers/user.rb +7 -6
- data/lib/sprinkle/package.rb +55 -51
- data/lib/sprinkle/package/chooser.rb +5 -4
- data/lib/sprinkle/package/rendering.rb +2 -2
- data/lib/sprinkle/policy.rb +13 -13
- data/lib/sprinkle/script.rb +5 -1
- data/lib/sprinkle/verify.rb +1 -0
- data/lib/sprinkle/version.rb +1 -1
- data/spec/spec_helper.rb +13 -7
- data/spec/sprinkle/actors/capistrano_spec.rb +18 -18
- data/spec/sprinkle/actors/local_spec.rb +3 -3
- data/spec/sprinkle/deployment_spec.rb +3 -3
- data/spec/sprinkle/installers/apt_spec.rb +1 -1
- data/spec/sprinkle/installers/binary_spec.rb +1 -1
- data/spec/sprinkle/installers/brew_spec.rb +1 -1
- data/spec/sprinkle/installers/bsd_port_spec.rb +1 -1
- data/spec/sprinkle/installers/file_spec.rb +9 -9
- data/spec/sprinkle/installers/freebsd_pkg_spec.rb +1 -1
- data/spec/sprinkle/installers/freebsd_portinstall_spec.rb +1 -1
- data/spec/sprinkle/installers/gem_spec.rb +1 -1
- data/spec/sprinkle/installers/installer_spec.rb +62 -25
- data/spec/sprinkle/installers/mac_port_spec.rb +1 -1
- data/spec/sprinkle/installers/npm_spec.rb +1 -1
- data/spec/sprinkle/installers/openbsd_pkg_spec.rb +1 -1
- data/spec/sprinkle/installers/opensolaris_pkg_spec.rb +1 -1
- data/spec/sprinkle/installers/pear_spec.rb +1 -1
- data/spec/sprinkle/installers/push_text_spec.rb +12 -12
- data/spec/sprinkle/installers/rake_spec.rb +1 -1
- data/spec/sprinkle/installers/replace_text_spec.rb +10 -10
- data/spec/sprinkle/installers/rpm_spec.rb +1 -1
- data/spec/sprinkle/installers/runner_spec.rb +9 -9
- data/spec/sprinkle/installers/smart_spec.rb +1 -1
- data/spec/sprinkle/installers/source_spec.rb +22 -27
- data/spec/sprinkle/installers/thor_spec.rb +1 -1
- data/spec/sprinkle/installers/transfer_spec.rb +35 -35
- data/spec/sprinkle/installers/user_spec.rb +13 -7
- data/spec/sprinkle/installers/yum_spec.rb +1 -1
- data/spec/sprinkle/installers/zypper_spec.rb +1 -1
- data/spec/sprinkle/package/package_repository_spec.rb +7 -7
- data/spec/sprinkle/package_spec.rb +58 -58
- data/spec/sprinkle/policy_spec.rb +20 -20
- data/spec/sprinkle/script_spec.rb +1 -1
- data/spec/sprinkle/verify_spec.rb +2 -2
- metadata +2 -2
@@ -3,7 +3,7 @@ require File.expand_path("../../spec_helper", File.dirname(__FILE__))
|
|
3
3
|
describe Sprinkle::Installers::Thor do
|
4
4
|
|
5
5
|
before do
|
6
|
-
@package =
|
6
|
+
@package = double(Sprinkle::Package, :name => 'spec')
|
7
7
|
end
|
8
8
|
|
9
9
|
def create_thor(names, options = {}, &block)
|
@@ -5,11 +5,11 @@ describe Sprinkle::Installers::Transfer do
|
|
5
5
|
include Sprinkle::Deployment
|
6
6
|
|
7
7
|
before do
|
8
|
-
@package =
|
8
|
+
@package = double(Sprinkle::Package, :name => 'package', :sudo? => false)
|
9
9
|
@empty = Proc.new { }
|
10
|
-
@delivery =
|
11
|
-
|
12
|
-
|
10
|
+
@delivery = double(Sprinkle::Deployment, :install => true)
|
11
|
+
@source = 'source'
|
12
|
+
@destination = 'destination'
|
13
13
|
@installer = create_transfer(@source, @destination)
|
14
14
|
@roles = []
|
15
15
|
@deployment = deployment do
|
@@ -21,13 +21,13 @@ describe Sprinkle::Installers::Transfer do
|
|
21
21
|
def create_transfer(source, dest, options={}, &block)
|
22
22
|
i = Sprinkle::Installers::Transfer.new(@package, source, dest, options, &block)
|
23
23
|
i.delivery = @delivery
|
24
|
-
|
24
|
+
i
|
25
25
|
end
|
26
26
|
|
27
27
|
describe 'when created' do
|
28
28
|
it 'should accept a source and destination to install' do
|
29
|
-
@installer.source.should
|
30
|
-
@installer.destination.should
|
29
|
+
@installer.source.should eq @source
|
30
|
+
@installer.destination.should eq @destination
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -63,7 +63,7 @@ describe Sprinkle::Installers::Transfer do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should call the pre and post install commands around the file transfer" do
|
66
|
-
@installer_commands.should
|
66
|
+
@installer_commands.should eq ["op1",:TRANSFER, "op2"]
|
67
67
|
end
|
68
68
|
|
69
69
|
# it "should call transfer with recursive defaulted to nil" do
|
@@ -85,7 +85,7 @@ describe Sprinkle::Installers::Transfer do
|
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should call the pre and post install commands around the file transfer" do
|
88
|
-
@installer_commands.should
|
88
|
+
@installer_commands.should eq ["op1",:TRANSFER,
|
89
89
|
"sudo mv /tmp/sprinkle_destination destination", "op2"]
|
90
90
|
end
|
91
91
|
end
|
@@ -101,52 +101,52 @@ describe Sprinkle::Installers::Transfer do
|
|
101
101
|
end
|
102
102
|
|
103
103
|
it "should call the pre and post install commands around the file transfer" do
|
104
|
-
@installer_commands.should
|
104
|
+
@installer_commands.should eq ["op1","op1-1",:TRANSFER, "op2","op2-1"]
|
105
105
|
end
|
106
106
|
|
107
107
|
end
|
108
108
|
|
109
|
-
|
109
|
+
after do
|
110
110
|
@installer.process @roles
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
-
|
115
|
-
|
114
|
+
describe "if the :render flag is true" do
|
115
|
+
before do
|
116
|
+
allow(::ActiveSupport::Deprecation).to receive(:warn)
|
116
117
|
@installer = create_transfer @source, @destination, :render => true
|
117
|
-
|
118
|
-
|
118
|
+
@delivery = @installer.delivery
|
119
|
+
@delivery.stub(:render_template_file)
|
120
|
+
@tempfile = Tempfile.new("foo")
|
119
121
|
end
|
120
122
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
end
|
123
|
+
it "should render the source file as a template to a tempfile" do
|
124
|
+
@installer.should_receive(:render_template_file).with(@source, anything, @package.name).and_return(@tempfile)
|
125
|
+
@delivery.stub(:transfer)
|
126
|
+
end
|
126
127
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
end
|
128
|
+
it "should call transfer with recursive set to false" do
|
129
|
+
@installer.should_receive(:render_template_file).with(@source, anything, @package.name).and_return(@tempfile)
|
130
|
+
@installer.options[:recursive].should eq false
|
131
|
+
end
|
132
132
|
|
133
|
-
|
133
|
+
after do
|
134
134
|
@installer.process @roles
|
135
135
|
end
|
136
|
-
|
136
|
+
end
|
137
137
|
|
138
|
-
|
139
|
-
|
138
|
+
describe "if the :recursive flag is explicitly set to false" do
|
139
|
+
before do
|
140
140
|
@installer = create_transfer @source, @destination, :recursive => false
|
141
141
|
end
|
142
142
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
143
|
+
it "should call transfer with recursive set to false" do
|
144
|
+
@installer.delivery
|
145
|
+
@installer.options[:recursive].should eq false
|
146
|
+
end
|
147
147
|
|
148
|
-
|
148
|
+
after do
|
149
149
|
@installer.process @roles
|
150
150
|
end
|
151
|
-
|
151
|
+
end
|
152
152
|
end
|
@@ -3,34 +3,40 @@ require File.expand_path("../../spec_helper", File.dirname(__FILE__))
|
|
3
3
|
describe Sprinkle::Installers::User do
|
4
4
|
|
5
5
|
before do
|
6
|
-
@package =
|
6
|
+
@package = double(Sprinkle::Package, :name => 'spec', :sudo? => false)
|
7
7
|
@user = "bob"
|
8
8
|
end
|
9
9
|
|
10
10
|
def create_user(name, options = {}, &block)
|
11
|
-
Sprinkle::Installers::User.new
|
11
|
+
Sprinkle::Installers::User.new @package, name, options, &block
|
12
12
|
end
|
13
13
|
|
14
14
|
describe 'during installation' do
|
15
|
-
|
15
|
+
|
16
16
|
it "should invoke add user" do
|
17
17
|
@installer = create_user 'bob'
|
18
18
|
@install_commands = @installer.send :install_commands
|
19
|
-
@install_commands.should == "adduser
|
19
|
+
@install_commands.should == "adduser --gecos ,,, bob"
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
it "should merge flags" do
|
23
23
|
@installer = create_user 'bob', :flags => "-x"
|
24
24
|
@install_commands = @installer.send :install_commands
|
25
25
|
@install_commands.should == "adduser -x --gecos ,,, bob"
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
it "should use actual gecos options if passed" do
|
29
29
|
@installer = create_user 'bob', :flags => "--gecos bob,,,"
|
30
30
|
@install_commands = @installer.send :install_commands
|
31
31
|
@install_commands.should == "adduser --gecos bob,,, bob"
|
32
32
|
end
|
33
33
|
|
34
|
+
it "should use sudo if sudo specified" do
|
35
|
+
@installer = create_user 'bob', :sudo => true
|
36
|
+
@install_commands = @installer.send :install_commands
|
37
|
+
@install_commands.should == "sudo adduser --gecos ,,, bob"
|
38
|
+
end
|
39
|
+
|
34
40
|
end
|
35
41
|
|
36
|
-
end
|
42
|
+
end
|
@@ -3,7 +3,7 @@ require File.expand_path("../../spec_helper", File.dirname(__FILE__))
|
|
3
3
|
describe Sprinkle::Installers::Yum do
|
4
4
|
|
5
5
|
before do
|
6
|
-
@package =
|
6
|
+
@package = double(Sprinkle::Package, :name => 'package')
|
7
7
|
end
|
8
8
|
|
9
9
|
def create_rpm(rpms, &block)
|
@@ -3,7 +3,7 @@ require File.expand_path("../../spec_helper", File.dirname(__FILE__))
|
|
3
3
|
describe Sprinkle::Installers::Zypper do
|
4
4
|
|
5
5
|
before do
|
6
|
-
@package =
|
6
|
+
@package = double(Sprinkle::Package, :name => 'package')
|
7
7
|
end
|
8
8
|
|
9
9
|
def create_zypper(*packages, &block)
|
@@ -14,33 +14,33 @@ describe Sprinkle::Package::PackageRepository do
|
|
14
14
|
|
15
15
|
it 'should allow adding a package' do
|
16
16
|
@repository.add @test_package
|
17
|
-
@repository.count.should
|
17
|
+
@repository.count.should eq 1
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'should allow clearing' do
|
21
21
|
@repository.add @test_package
|
22
22
|
@repository.clear
|
23
|
-
@repository.count.should
|
23
|
+
@repository.count.should eq 0
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should find by provides" do
|
27
27
|
@repository.add @mysql_package
|
28
|
-
@repository.find_all("db").should
|
28
|
+
@repository.find_all("db").should eq [ @mysql_package ]
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should find by name" do
|
32
32
|
@repository.add @test_package
|
33
|
-
@repository.find_all("test").should
|
33
|
+
@repository.find_all("test").should eq [ @test_package ]
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should filter by version" do
|
37
37
|
@repository.add @test_package
|
38
38
|
@repository.add @test_v2_package
|
39
|
-
@repository.find_all("test").size.should
|
40
|
-
@repository.first("test", :version => "2").should
|
39
|
+
@repository.find_all("test").size.should eq 2
|
40
|
+
@repository.first("test", :version => "2").should eq @test_v2_package
|
41
41
|
end
|
42
42
|
|
43
43
|
after do
|
44
44
|
end
|
45
45
|
|
46
|
-
end
|
46
|
+
end
|
@@ -8,7 +8,7 @@ describe Sprinkle::Package do
|
|
8
8
|
@empty = Proc.new { }
|
9
9
|
@opts = { }
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
after do
|
13
13
|
Sprinkle::Package::PACKAGES.clear
|
14
14
|
end
|
@@ -56,14 +56,14 @@ CODE
|
|
56
56
|
pkg = package @name do
|
57
57
|
description 'my package description'
|
58
58
|
end
|
59
|
-
pkg.description.should
|
59
|
+
pkg.description.should eq 'my package description'
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'should optionally accept a version' do
|
63
63
|
pkg = package @name do
|
64
64
|
version '2.0.2'
|
65
65
|
end
|
66
|
-
pkg.version.should
|
66
|
+
pkg.version.should eq '2.0.2'
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'should optionally accept configuration defaults' do
|
@@ -87,14 +87,14 @@ CODE
|
|
87
87
|
defaults :username => 'deploy'
|
88
88
|
add_user opts[:username]
|
89
89
|
end
|
90
|
-
pkg.installers.first.class.should
|
90
|
+
pkg.installers.first.class.should eq Sprinkle::Installers::User
|
91
91
|
install_commands = pkg.installers.first.send :install_commands
|
92
|
-
install_commands.should == 'adduser
|
92
|
+
install_commands.should == 'adduser --gecos ,,, deploy'
|
93
93
|
|
94
94
|
instance = pkg.instance :username => 'deployer'
|
95
95
|
|
96
96
|
install_commands = instance.installers.first.send :install_commands
|
97
|
-
install_commands.should == 'adduser
|
97
|
+
install_commands.should == 'adduser --gecos ,,, deployer'
|
98
98
|
end
|
99
99
|
|
100
100
|
it 'should optionally accept an installer' do
|
@@ -108,31 +108,31 @@ CODE
|
|
108
108
|
pkg = package @name do
|
109
109
|
requires :webserver, :database
|
110
110
|
end
|
111
|
-
pkg.dependencies.should
|
111
|
+
pkg.dependencies.should eq [:webserver, :database]
|
112
112
|
end
|
113
113
|
|
114
114
|
it 'should optionally accept recommended dependencies' do
|
115
115
|
pkg = package @name do
|
116
116
|
recommends :webserver, :database
|
117
117
|
end
|
118
|
-
pkg.recommends.should
|
118
|
+
pkg.recommends.should eq [:webserver, :database]
|
119
119
|
end
|
120
120
|
|
121
121
|
it 'should optionally accept optional dependencies' do
|
122
122
|
pkg = package @name do
|
123
123
|
optional :webserver_configuration, :database_configuration
|
124
124
|
end
|
125
|
-
pkg.optional.should
|
125
|
+
pkg.optional.should eq [:webserver_configuration, :database_configuration]
|
126
126
|
end
|
127
127
|
|
128
128
|
it 'should optionally define a virtual package implementation' do
|
129
129
|
pkg = package @name, :provides => :database do; end
|
130
|
-
pkg.provides.should
|
130
|
+
pkg.provides.should eq :database
|
131
131
|
end
|
132
132
|
|
133
133
|
it 'should be able to represent itself as a string' do
|
134
134
|
pkg = package @name do; end
|
135
|
-
pkg.to_s.should
|
135
|
+
pkg.to_s.should eq @name.to_s
|
136
136
|
end
|
137
137
|
|
138
138
|
end
|
@@ -140,8 +140,8 @@ CODE
|
|
140
140
|
describe 'helper method' do
|
141
141
|
|
142
142
|
it 'should add new packages to the global package repository' do
|
143
|
-
|
144
|
-
Sprinkle::Package::PACKAGES.count.should
|
143
|
+
package @name do; end
|
144
|
+
Sprinkle::Package::PACKAGES.count.should eq 1
|
145
145
|
end
|
146
146
|
|
147
147
|
end
|
@@ -153,7 +153,7 @@ CODE
|
|
153
153
|
apt %w( deb1 deb2 )
|
154
154
|
end
|
155
155
|
pkg.should respond_to(:apt)
|
156
|
-
pkg.installers.first.class.should
|
156
|
+
pkg.installers.first.class.should eq Sprinkle::Installers::Apt
|
157
157
|
end
|
158
158
|
|
159
159
|
it 'should optionally accept an rpm installer' do
|
@@ -161,7 +161,7 @@ CODE
|
|
161
161
|
rpm %w( rpm1 rpm2 )
|
162
162
|
end
|
163
163
|
pkg.should respond_to(:rpm)
|
164
|
-
pkg.installers.first.class.should
|
164
|
+
pkg.installers.first.class.should eq Sprinkle::Installers::Rpm
|
165
165
|
end
|
166
166
|
|
167
167
|
it 'should optionally accept a gem installer' do
|
@@ -169,7 +169,7 @@ CODE
|
|
169
169
|
gem 'gem'
|
170
170
|
end
|
171
171
|
pkg.should respond_to(:gem)
|
172
|
-
pkg.installers.first.class.should
|
172
|
+
pkg.installers.first.class.should eq Sprinkle::Installers::Gem
|
173
173
|
end
|
174
174
|
|
175
175
|
it 'should optionally accept a noop installer' do
|
@@ -178,10 +178,10 @@ CODE
|
|
178
178
|
end
|
179
179
|
end
|
180
180
|
pkg.should respond_to(:noop)
|
181
|
-
pkg.installers.first.class.should
|
181
|
+
pkg.installers.first.class.should eq Sprinkle::Installers::Runner
|
182
182
|
@installer = pkg.installers.first
|
183
183
|
@install_commands = @installer.send :install_commands
|
184
|
-
@install_commands.should
|
184
|
+
@install_commands.should eq ['echo noop']
|
185
185
|
end
|
186
186
|
|
187
187
|
it 'should optionally accept an group installer' do
|
@@ -189,7 +189,7 @@ CODE
|
|
189
189
|
add_group 'bob'
|
190
190
|
end
|
191
191
|
pkg.should respond_to(:add_group)
|
192
|
-
pkg.installers.first.class.should
|
192
|
+
pkg.installers.first.class.should eq Sprinkle::Installers::Group
|
193
193
|
end
|
194
194
|
|
195
195
|
it 'should optionally accept a source installer' do
|
@@ -197,7 +197,7 @@ CODE
|
|
197
197
|
source 'archive'
|
198
198
|
end
|
199
199
|
pkg.should respond_to(:source)
|
200
|
-
pkg.installers.first.class.should
|
200
|
+
pkg.installers.first.class.should eq Sprinkle::Installers::Source
|
201
201
|
end
|
202
202
|
|
203
203
|
it 'should optionally accept an user installer' do
|
@@ -205,7 +205,7 @@ CODE
|
|
205
205
|
add_user 'bob'
|
206
206
|
end
|
207
207
|
pkg.should respond_to(:add_user)
|
208
|
-
pkg.installers.first.class.should
|
208
|
+
pkg.installers.first.class.should eq Sprinkle::Installers::User
|
209
209
|
end
|
210
210
|
|
211
211
|
it 'should allow multiple installer steps to be defined and respect order' do
|
@@ -214,9 +214,9 @@ CODE
|
|
214
214
|
gem 'momoney'
|
215
215
|
end
|
216
216
|
|
217
|
-
pkg.installers.length.should
|
218
|
-
pkg.installers[0].class.should
|
219
|
-
pkg.installers[1].class.should
|
217
|
+
pkg.installers.length.should eq 2
|
218
|
+
pkg.installers[0].class.should eq Sprinkle::Installers::Source
|
219
|
+
pkg.installers[1].class.should eq Sprinkle::Installers::Gem
|
220
220
|
end
|
221
221
|
|
222
222
|
it 'should optionally accept a runner installer' do
|
@@ -224,7 +224,7 @@ CODE
|
|
224
224
|
runner 'obscure_installer_by_custom_cmd'
|
225
225
|
end
|
226
226
|
pkg.should respond_to(:runner)
|
227
|
-
pkg.installers.first.class.should
|
227
|
+
pkg.installers.first.class.should eq Sprinkle::Installers::Runner
|
228
228
|
end
|
229
229
|
end
|
230
230
|
|
@@ -235,7 +235,7 @@ CODE
|
|
235
235
|
source 'archive' do; end
|
236
236
|
end
|
237
237
|
pkg.should respond_to(:source)
|
238
|
-
pkg.installers.first.class.should
|
238
|
+
pkg.installers.first.class.should eq Sprinkle::Installers::Source
|
239
239
|
end
|
240
240
|
|
241
241
|
it 'should forward block to installer superclass' do
|
@@ -281,16 +281,16 @@ CODE
|
|
281
281
|
describe 'when processing' do
|
282
282
|
|
283
283
|
before do
|
284
|
-
@deployment =
|
284
|
+
@deployment = double(Sprinkle::Deployment)
|
285
285
|
@roles = [ :app, :db ]
|
286
|
-
@installer =
|
286
|
+
@installer = double(Sprinkle::Installers::Installer, :defaults => true, :process => true)
|
287
287
|
@package = package @name do; end
|
288
288
|
end
|
289
289
|
|
290
290
|
describe 'with an installer' do
|
291
291
|
|
292
292
|
before do
|
293
|
-
@package.installers
|
293
|
+
@package.installers << @installer
|
294
294
|
end
|
295
295
|
|
296
296
|
it 'should configure itself against the deployment context' do
|
@@ -318,9 +318,9 @@ CODE
|
|
318
318
|
describe 'with verifications' do
|
319
319
|
before do
|
320
320
|
@pkg = create_package_with_blank_verify(3)
|
321
|
-
@pkg.installers
|
322
|
-
@installer.stub
|
323
|
-
@installer.stub
|
321
|
+
@pkg.installers.replace [ @installer ]
|
322
|
+
@installer.stub(:defaults)
|
323
|
+
@installer.stub(:process)
|
324
324
|
end
|
325
325
|
|
326
326
|
describe 'with forcing' do
|
@@ -366,7 +366,8 @@ CODE
|
|
366
366
|
after do
|
367
367
|
begin
|
368
368
|
@pkg.process(@deployment, @roles)
|
369
|
-
rescue Sprinkle::VerificationFailed
|
369
|
+
rescue Sprinkle::VerificationFailed
|
370
|
+
end
|
370
371
|
end
|
371
372
|
end
|
372
373
|
end
|
@@ -375,35 +376,35 @@ CODE
|
|
375
376
|
|
376
377
|
describe 'when processing verifications' do
|
377
378
|
before do
|
378
|
-
@deployment =
|
379
|
+
@deployment = double(Sprinkle::Deployment)
|
379
380
|
@roles = [ :app, :db ]
|
380
|
-
@installer =
|
381
|
+
@installer = double(Sprinkle::Installers::Installer, :defaults => true, :process => true)
|
381
382
|
@pkg = create_package_with_blank_verify(3)
|
382
|
-
@pkg.installers
|
383
|
-
@installer.stub
|
384
|
-
@installer.stub
|
385
|
-
@logger =
|
386
|
-
@logger.stub
|
383
|
+
@pkg.installers.replace [ @installer ]
|
384
|
+
@installer.stub(:defaults)
|
385
|
+
@installer.stub(:process)
|
386
|
+
@logger = double(:debug => true, :debug? => true)
|
387
|
+
@logger.stub(:info)
|
387
388
|
end
|
388
389
|
|
389
390
|
it 'should request _each_ verification to configure itself against the deployment context' do
|
390
391
|
@pkg.verifications.each do |v|
|
391
392
|
v.should_receive(:defaults).with(@deployment).once
|
392
|
-
v.stub
|
393
|
+
v.stub(:process)
|
393
394
|
end
|
394
395
|
end
|
395
396
|
|
396
397
|
it 'should request _each_ verification to process' do
|
397
398
|
@pkg.verifications.each do |v|
|
398
|
-
v.stub
|
399
|
+
v.stub(:defaults)
|
399
400
|
v.should_receive(:process).with(@roles).once
|
400
401
|
end
|
401
402
|
end
|
402
403
|
|
403
404
|
it 'should enter a log info event to notify user whats happening' do
|
404
405
|
@pkg.verifications.each do |v|
|
405
|
-
v.stub
|
406
|
-
v.stub
|
406
|
+
v.stub(:defaults)
|
407
|
+
v.stub(:process)
|
407
408
|
end
|
408
409
|
|
409
410
|
@pkg.should_receive(:logger).once.and_return(@logger)
|
@@ -426,16 +427,15 @@ CODE
|
|
426
427
|
|
427
428
|
it 'should be able to return a dependency hierarchy tree' do
|
428
429
|
@ai, @bi, @ci, @di, @ei = @a, @b, @c, @d, @e
|
429
|
-
@b.should_receive(:instance).
|
430
|
-
@c.should_receive(:instance).
|
431
|
-
@d.should_receive(:instance).
|
432
|
-
|
433
|
-
|
434
|
-
@
|
435
|
-
@
|
436
|
-
@
|
437
|
-
@
|
438
|
-
@e.tree.flatten.should == [ @e, @d ]
|
430
|
+
@b.should_receive(:instance).at_least(:once).and_return(@bi)
|
431
|
+
@c.should_receive(:instance).at_least(:once).and_return(@ci)
|
432
|
+
@d.should_receive(:instance).at_least(:once).and_return(@di)
|
433
|
+
|
434
|
+
@a.tree.flatten.should eq [ @d, @c, @b, @a ]
|
435
|
+
@b.tree.flatten.should eq [ @d, @c, @b ]
|
436
|
+
@c.tree.flatten.should eq [ @d, @c ]
|
437
|
+
@d.tree.flatten.should eq [ @d ]
|
438
|
+
@e.tree.flatten.should eq [ @e, @d ]
|
439
439
|
end
|
440
440
|
|
441
441
|
describe 'with missing recommendations' do
|
@@ -445,7 +445,7 @@ CODE
|
|
445
445
|
end
|
446
446
|
|
447
447
|
it 'should ignore missing recommendations' do
|
448
|
-
@d.tree.flatten.should
|
448
|
+
@d.tree.flatten.should eq [ @d ]
|
449
449
|
end
|
450
450
|
|
451
451
|
end
|
@@ -457,7 +457,7 @@ CODE
|
|
457
457
|
end
|
458
458
|
|
459
459
|
it 'should ignore missing recommendations' do
|
460
|
-
@d.tree.flatten.should
|
460
|
+
@d.tree.flatten.should eq [ @d ]
|
461
461
|
end
|
462
462
|
|
463
463
|
end
|
@@ -467,11 +467,11 @@ CODE
|
|
467
467
|
@a.tree do
|
468
468
|
@count += 1
|
469
469
|
end
|
470
|
-
@count.should
|
470
|
+
@count.should eq 3
|
471
471
|
end
|
472
472
|
|
473
473
|
it 'should maintain a depth count of how deep the hierarchy is' do
|
474
|
-
instance=
|
474
|
+
instance=double
|
475
475
|
@b.should_receive(:instance).and_return(instance)
|
476
476
|
instance.should_receive(:tree).with(2).and_return([@b])
|
477
477
|
@a.tree do; end
|