-
Notifications
You must be signed in to change notification settings - Fork 217
/
capifony_symfony2_symfony_spec.rb
334 lines (263 loc) · 14.5 KB
/
capifony_symfony2_symfony_spec.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
require 'spec_helper'
describe "Capifony::Symfony2 - symfony" do
before do
@configuration = Capistrano::Configuration.new
@configuration.extend(Capistrano::Spec::ConfigurationExtension)
# Common parameters
@configuration.set :latest_release, '/var/www/releases/20120927'
@configuration.set :previous_release, '/var/www/releases/20120920'
@configuration.set :current_path, '/var/www/current'
@configuration.set :shared_path, '/var/www/shared'
@configuration.set :maintenance_basename, 'maintenance'
@configuration.set :try_sudo, ''
Capifony::Symfony2.load_into(@configuration)
end
subject { @configuration }
it "defines a symfony namespace" do
@configuration.find_task('symfony').should_not == nil
end
it "defines symfony:logs tasks" do
@configuration.find_task('symfony:logs:tail').should_not == nil
@configuration.find_task('symfony:logs:tail_dev').should_not == nil
end
context "when running symfony:logs:tail" do
before do
@configuration.find_and_execute_task('symfony:logs:tail')
end
it { should have_run(' tail -n 50 -f /var/www/shared/app/logs/prod.log') }
end
context "when running symfony:logs:tail_dev" do
before do
@configuration.find_and_execute_task('symfony:logs:tail_dev')
end
it { should have_run(' tail -n 50 -f /var/www/shared/app/logs/dev.log') }
end
it "defines symfony:assets tasks" do
@configuration.find_task('symfony:assets:update_version').should_not == nil
@configuration.find_task('symfony:assets:install').should_not == nil
end
context "when running symfony:assets:install" do
before do
@configuration.find_and_execute_task('symfony:assets:install')
end
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && php app/console assets:install web --env=prod --no-debug\'') }
end
context "when running symfony:assets:install" do
before do
@configuration.set :assets_symlinks, true
@configuration.find_and_execute_task('symfony:assets:install')
end
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && php app/console assets:install web --symlink --env=prod --no-debug\'') }
end
context "when running symfony:assets:install" do
before do
@configuration.set :assets_relative, true
@configuration.find_and_execute_task('symfony:assets:install')
end
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && php app/console assets:install web --relative --env=prod --no-debug\'') }
end
context "when running symfony:assets:install" do
before do
@configuration.set :assets_symlinks, true
@configuration.set :assets_relative, true
@configuration.find_and_execute_task('symfony:assets:install')
end
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && php app/console assets:install web --symlink --relative --env=prod --no-debug\'') }
end
context "when running symfony:assets:install with sudo" do
before do
@configuration.set :try_sudo, 'sudo'
@configuration.find_and_execute_task('symfony:assets:install')
end
it { should have_run('sudo sh -c \'cd /var/www/releases/20120927 && php app/console assets:install web --env=prod --no-debug\'') }
end
context "when running symfony:assets:install with a custom assets_install_path" do
before do
@configuration.set :assets_install_path, 'some/where'
@configuration.find_and_execute_task('symfony:assets:install')
end
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && php app/console assets:install some/where --env=prod --no-debug\'') }
end
it "defines symfony:assetic tasks" do
@configuration.find_task('symfony:assetic:dump').should_not == nil
end
context "when running symfony:assetic:dump" do
before do
@configuration.find_and_execute_task('symfony:assetic:dump')
end
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && php app/console assetic:dump --env=prod --no-debug\'') }
end
context "when running symfony:assetic:dump with sudo" do
before do
@configuration.set :try_sudo, 'sudo'
@configuration.find_and_execute_task('symfony:assetic:dump')
end
it { should have_run('sudo sh -c \'cd /var/www/releases/20120927 && php app/console assetic:dump --env=prod --no-debug\'') }
end
it "defines symfony:vendors tasks" do
@configuration.find_task('symfony:vendors:install').should_not == nil
@configuration.find_task('symfony:vendors:reinstall').should_not == nil
@configuration.find_task('symfony:vendors:upgrade').should_not == nil
end
context "when running symfony:vendors:install" do
before do
@configuration.find_and_execute_task('symfony:vendors:install')
end
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && php bin/vendors install\'') }
end
context "when running symfony:vendors:reinstall" do
before do
@configuration.find_and_execute_task('symfony:vendors:reinstall')
end
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && php bin/vendors install --reinstall\'') }
end
context "when running symfony:vendors:upgrade" do
before do
@configuration.find_and_execute_task('symfony:vendors:upgrade')
end
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && php bin/vendors update\'') }
end
it "defines symfony:bootstrap tasks" do
@configuration.find_task('symfony:bootstrap:build').should_not == nil
end
it "defines symfony:composer tasks" do
@configuration.find_task('symfony:composer:install').should_not == nil
@configuration.find_task('symfony:composer:update').should_not == nil
@configuration.find_task('symfony:composer:dump_autoload').should_not == nil
@configuration.find_task('symfony:composer:copy_vendors').should_not == nil
end
context "when running symfony:composer:update" do
before do
@configuration.find_and_execute_task('symfony:composer:update')
end
it { should_not have_run('vendorDir=/var/www/current/vendor; if [ -d $vendorDir ] || [ -h $vendorDir ]; then cp -a $vendorDir /var/www/releases/20120927; fi;') }
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && curl -s http://getcomposer.org/installer | php\'') }
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && SYMFONY_ENV=prod php composer.phar update --no-dev --verbose --prefer-dist --optimize-autoloader --no-progress\'') }
end
context "when running symfony:composer:update with interactive_mode disabled" do
before do
@configuration.set :interactive_mode, false
@configuration.find_and_execute_task('symfony:composer:update')
end
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && SYMFONY_ENV=prod php composer.phar update --no-dev --verbose --prefer-dist --optimize-autoloader --no-progress --no-interaction\'') }
end
context "when running symfony:composer:update with a given composer_bin" do
before do
@configuration.set :composer_bin, "my_composer"
@configuration.find_and_execute_task('symfony:composer:update')
end
it { should_not have_run('vendorDir=/var/www/current/vendor; if [ -d $vendorDir ] || [ -h $vendorDir ]; then cp -a $vendorDir /var/www/releases/20120927; fi;') }
it { should_not have_run(' sh -c \'cd /var/www/releases/20120927 && curl -s http://getcomposer.org/installer | php\'') }
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && SYMFONY_ENV=prod my_composer update --no-dev --verbose --prefer-dist --optimize-autoloader --no-progress\'') }
end
context "when running symfony:composer:update with enabled copy_vendors" do
before do
@configuration.set :copy_vendors, true
@configuration.find_and_execute_task('symfony:composer:update')
end
it { should have_run('vendorDir=/var/www/current/vendor; if [ -d $vendorDir ] || [ -h $vendorDir ]; then cp -a $vendorDir /var/www/releases/20120927; fi;') }
end
context "when running symfony:composer:install with an existing composer.phar in the previous release" do
before do
@configuration.stub(:remote_file_exists?).and_return(true)
@configuration.find_and_execute_task('symfony:composer:install')
end
it { should_not have_run('vendorDir=/var/www/current/vendor; if [ -d $vendorDir ] || [ -h $vendorDir ]; then cp -a $vendorDir /var/www/releases/20120927; fi;') }
it { should_not have_run(' sh -c \'cp /var/www/releases/20120920/composer.phar /var/www/releases/20120927/\'') }
it { should_not have_run(' sh -c \'cd /var/www/releases/20120927 && curl -s http://getcomposer.org/installer | php\'') }
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && php composer.phar self-update\'') }
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && SYMFONY_ENV=prod php composer.phar install --no-dev --verbose --prefer-dist --optimize-autoloader --no-progress\'') }
end
context "when running symfony:composer:install without any existing composer.phar in the previous release" do
before do
@configuration.stub(:remote_file_exists?).and_return(false)
@configuration.find_and_execute_task('symfony:composer:install')
end
it { should_not have_run('vendorDir=/var/www/current/vendor; if [ -d $vendorDir ] || [ -h $vendorDir ]; then cp -a $vendorDir /var/www/releases/20120927; fi;') }
it { should_not have_run(' sh -c \'cp /var/www/releases/20120920/composer.phar /var/www/releases/20120927/\'') }
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && curl -s http://getcomposer.org/installer | php\'') }
it { should_not have_run(' sh -c \'cd /var/www/releases/20120927 && php composer.phar self-update\'') }
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && SYMFONY_ENV=prod php composer.phar install --no-dev --verbose --prefer-dist --optimize-autoloader --no-progress\'') }
end
context "when running symfony:composer:install" do
before do
@configuration.find_and_execute_task('symfony:composer:install')
end
it { should_not have_run('vendorDir=/var/www/current/vendor; if [ -d $vendorDir ] || [ -h $vendorDir ]; then cp -a $vendorDir /var/www/releases/20120927; fi;') }
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && curl -s http://getcomposer.org/installer | php\'') }
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && SYMFONY_ENV=prod php composer.phar install --no-dev --verbose --prefer-dist --optimize-autoloader --no-progress\'') }
end
context "when running symfony:composer:install with interactive mode disabled" do
before do
@configuration.set :interactive_mode, false
@configuration.find_and_execute_task('symfony:composer:install')
end
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && SYMFONY_ENV=prod php composer.phar install --no-dev --verbose --prefer-dist --optimize-autoloader --no-progress --no-interaction\'') }
end
context "when running symfony:composer:install with a given composer_bin" do
before do
@configuration.set :composer_bin, "my_composer"
@configuration.find_and_execute_task('symfony:composer:install')
end
it { should_not have_run('vendorDir=/var/www/current/vendor; if [ -d $vendorDir ] || [ -h $vendorDir ]; then cp -a $vendorDir /var/www/releases/20120927/vendor; fi;') }
it { should_not have_run(' sh -c \'cd /var/www/releases/20120927 && curl -s http://getcomposer.org/installer | php\'') }
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && SYMFONY_ENV=prod my_composer install --no-dev --verbose --prefer-dist --optimize-autoloader --no-progress\'') }
end
context "when running symfony:composer:install with enabled copy_vendors" do
before do
@configuration.set :copy_vendors, true
@configuration.find_and_execute_task('symfony:composer:install')
end
it { should have_run('vendorDir=/var/www/current/vendor; if [ -d $vendorDir ] || [ -h $vendorDir ]; then cp -a $vendorDir /var/www/releases/20120927; fi;') }
end
context "when running symfony:composer:dump_autoload" do
before do
@configuration.find_and_execute_task('symfony:composer:dump_autoload')
end
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && curl -s http://getcomposer.org/installer | php\'') }
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && php composer.phar dump-autoload --optimize\'') }
end
context "when running symfony:composer:dump_autoload with a given composer_bin" do
before do
@configuration.set :composer_bin, "my_composer"
@configuration.find_and_execute_task('symfony:composer:dump_autoload')
end
it { should_not have_run(' sh -c \'cd /var/www/releases/20120927 && curl -s http://getcomposer.org/installer | php\'') }
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && my_composer dump-autoload --optimize\'') }
end
it "defines symfony:cache tasks" do
@configuration.find_task('symfony:cache:clear').should_not == nil
@configuration.find_task('symfony:cache:warmup').should_not == nil
end
context "when running symfony:cache:clear" do
before do
@configuration.find_and_execute_task('symfony:cache:clear')
end
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && php app/console cache:clear --env=prod --no-debug\'') }
it { should have_run(' chmod -R g+w /var/www/releases/20120927/app/cache') }
end
context "when running symfony:cache:warmup" do
before do
@configuration.find_and_execute_task('symfony:cache:warmup')
end
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && php app/console cache:warmup --env=prod --no-debug\'') }
it { should have_run(' chmod -R g+w /var/www/releases/20120927/app/cache') }
end
it "defines symfony:project tasks" do
@configuration.fetch(:controllers_to_clear).should == ['app_*.php']
@configuration.find_task('symfony:project:clear_controllers').should_not == nil
end
context "when running symfony:project:clear_controllers" do
before do
@configuration.find_and_execute_task('symfony:project:clear_controllers')
end
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && rm -f web/app_*.php\'') }
end
context "when running symfony:project:clear_controllers with a given controllers_to_clear" do
before do
@configuration.set :controllers_to_clear, ['config.php', 'app_dev.php', 'app_test.php']
@configuration.find_and_execute_task('symfony:project:clear_controllers')
end
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && rm -f web/config.php web/app_dev.php web/app_test.php\'') }
end
end