plow 0.1.0 → 1.0.0
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/.gitignore +2 -2
- data/.yardopts +4 -2
- data/README.markdown +86 -41
- data/Rakefile +34 -28
- data/VERSION +1 -1
- data/bin/plow +1 -7
- data/bin/plow1.9 +1 -7
- data/doc/HISTORY.markdown +41 -0
- data/doc/ROAD-MAP.markdown +12 -0
- data/{SECURITY → doc/SECURITY.markdown} +4 -3
- data/lib/plow/application.rb +33 -1
- data/lib/plow/binding_struct.rb +38 -2
- data/lib/plow/core_ext/object.rb +9 -1
- data/lib/plow/dependencies.rb +123 -0
- data/lib/plow/errors.rb +8 -0
- data/lib/plow/generator.rb +88 -6
- data/lib/plow/strategy/ubuntu_hardy.rb +316 -0
- data/lib/plow.rb +5 -11
- data/spec/plow/application_spec.rb +2 -2
- data/spec/plow/binding_struct_spec.rb +1 -1
- data/spec/plow/dependencies_spec.rb +175 -0
- data/spec/plow/errors_spec.rb +1 -1
- data/spec/plow/generator_spec.rb +6 -6
- data/spec/plow/strategy/{ubuntu_hardy/user_home_web_app_spec.rb → ubuntu_hardy_spec.rb} +96 -96
- data/spec/plow_spec.rb +2 -2
- data/spec/spec_helper.rb +0 -24
- metadata +25 -13
- data/HISTORY +0 -39
- data/ROAD-MAP +0 -10
- data/lib/plow/strategy/ubuntu_hardy/templates/README.txt +0 -19
- data/lib/plow/strategy/ubuntu_hardy/user_home_web_app.rb +0 -304
@@ -0,0 +1,175 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Plow::Dependencies do
|
5
|
+
|
6
|
+
##################################################################################################
|
7
|
+
|
8
|
+
describe "class constant and variable defaults" do
|
9
|
+
it "required ruby version should be correct" do
|
10
|
+
Plow::Dependencies::REQUIRED_RUBY_VERSION.should == '1.9.1'
|
11
|
+
end
|
12
|
+
|
13
|
+
it "development gem names and versions should be correct" do
|
14
|
+
expected = {
|
15
|
+
:jeweler => '1.3.0',
|
16
|
+
:rspec => '1.2.9',
|
17
|
+
:yard => '0.4.0',
|
18
|
+
:bluecloth => '2.0.5'
|
19
|
+
}
|
20
|
+
|
21
|
+
Plow::Dependencies::DEVELOPMENT_GEMS.should == expected
|
22
|
+
end
|
23
|
+
|
24
|
+
it "file name to gem name look-up table should be correct" do
|
25
|
+
expected = {
|
26
|
+
:spec => :rspec
|
27
|
+
}
|
28
|
+
Plow::Dependencies::FILE_NAME_TO_GEM_NAME.should == expected
|
29
|
+
end
|
30
|
+
|
31
|
+
it "warnings cache should be empty" do
|
32
|
+
Plow::Dependencies.class_variable_get(:@@warnings_cache).should be_empty
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
##################################################################################################
|
37
|
+
|
38
|
+
describe '.check_ruby_version (private)' do
|
39
|
+
before(:each) do
|
40
|
+
$stderr = StringIO.new
|
41
|
+
end
|
42
|
+
|
43
|
+
after(:each) do
|
44
|
+
$stderr = STDERR
|
45
|
+
end
|
46
|
+
|
47
|
+
def expected_message(version)
|
48
|
+
@expected_message = <<-ERROR
|
49
|
+
This library requires Ruby 1.9.1, but you're using #{version}.
|
50
|
+
Please visit http://www.ruby-lang.org/ for installation instructions.
|
51
|
+
ERROR
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should abort for ruby 1.8.6" do
|
55
|
+
version = '1.8.6'
|
56
|
+
lambda { Plow::Dependencies.send(:check_ruby_version, version) }.should raise_error(SystemExit, expected_message(version))
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should abort for ruby 1.8.7" do
|
60
|
+
version = '1.8.7'
|
61
|
+
lambda { Plow::Dependencies.send(:check_ruby_version, version) }.should raise_error(SystemExit, expected_message(version))
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should abort for ruby 1.9.0" do
|
65
|
+
version = '1.9.0'
|
66
|
+
lambda { Plow::Dependencies.send(:check_ruby_version, version) }.should raise_error(SystemExit, expected_message(version))
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should not abort for ruby 1.9.1" do
|
70
|
+
version = '1.9.1'
|
71
|
+
lambda { Plow::Dependencies.send(:check_ruby_version, version) }.should_not raise_error(SystemExit, expected_message(version))
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should abort for ruby 1.9.2" do
|
75
|
+
version = '1.9.2'
|
76
|
+
lambda { Plow::Dependencies.send(:check_ruby_version, version) }.should raise_error(SystemExit, expected_message(version))
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
##################################################################################################
|
81
|
+
|
82
|
+
describe '.destroy_warnings' do
|
83
|
+
it "should empty the warnings cache" do
|
84
|
+
Plow::Dependencies.class_variable_get(:@@warnings_cache).should be_empty
|
85
|
+
|
86
|
+
Plow::Dependencies.create_warning_for(LoadError.new("no such file to load -- jeweler"))
|
87
|
+
Plow::Dependencies.class_variable_get(:@@warnings_cache).should_not be_empty
|
88
|
+
|
89
|
+
Plow::Dependencies.destroy_warnings
|
90
|
+
Plow::Dependencies.class_variable_get(:@@warnings_cache).should be_empty
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
##################################################################################################
|
95
|
+
|
96
|
+
describe '.create_warning_for' do
|
97
|
+
after(:each) do
|
98
|
+
Plow::Dependencies.destroy_warnings
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should create and cache one warning from a known development gem dependency" do
|
102
|
+
Plow::Dependencies.create_warning_for(LoadError.new("no such file to load -- jeweler"))
|
103
|
+
Plow::Dependencies.class_variable_get(:@@warnings_cache).should == ["jeweler --version '1.3.0'"]
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should create and cache warnings from all known development gem dependencies" do
|
107
|
+
Plow::Dependencies::DEVELOPMENT_GEMS.each_key do |file_name|
|
108
|
+
gem_name = if Plow::Dependencies::FILE_NAME_TO_GEM_NAME.has_key?(file_name)
|
109
|
+
Plow::Dependencies::FILE_NAME_TO_GEM_NAME[file_name]
|
110
|
+
else
|
111
|
+
file_name
|
112
|
+
end
|
113
|
+
load_error = LoadError.new("no such file to load -- #{gem_name}")
|
114
|
+
Plow::Dependencies.create_warning_for(load_error)
|
115
|
+
end
|
116
|
+
|
117
|
+
expected = [
|
118
|
+
"jeweler --version '1.3.0'",
|
119
|
+
"rspec --version '1.2.9'",
|
120
|
+
"yard --version '0.4.0'",
|
121
|
+
"bluecloth --version '2.0.5'"
|
122
|
+
]
|
123
|
+
Plow::Dependencies.class_variable_get(:@@warnings_cache).should == expected
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should raise an exception when creating a warning from an unknown development gem dependency" do
|
127
|
+
lambda { Plow::Dependencies.create_warning_for(LoadError.new("no such file to load -- _fakegem")) }.should raise_error(RuntimeError, "Cannot create a dependency warning for unknown development gem -- _fakegem")
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
##################################################################################################
|
132
|
+
|
133
|
+
describe '.render_warnings' do
|
134
|
+
before(:each) do
|
135
|
+
$stdout = StringIO.new
|
136
|
+
end
|
137
|
+
|
138
|
+
after(:each) do
|
139
|
+
$stdout = STDOUT
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should display a warning message to the user on the standard output channel" do
|
143
|
+
Plow::Dependencies.create_warning_for(LoadError.new("no such file to load -- jeweler"))
|
144
|
+
Plow::Dependencies.create_warning_for(LoadError.new("no such file to load -- spec"))
|
145
|
+
Plow::Dependencies.create_warning_for(LoadError.new("no such file to load -- yard"))
|
146
|
+
Plow::Dependencies.create_warning_for(LoadError.new("no such file to load -- bluecloth"))
|
147
|
+
Plow::Dependencies.render_warnings
|
148
|
+
$stdout.string.should == <<-MESSAGE
|
149
|
+
|
150
|
+
The following development gem dependencies could not be found. Without them, some available development features are missing:
|
151
|
+
jeweler --version '1.3.0'
|
152
|
+
rspec --version '1.2.9'
|
153
|
+
yard --version '0.4.0'
|
154
|
+
bluecloth --version '2.0.5'
|
155
|
+
MESSAGE
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should not display a warning message to the user if there are no warnings in the cache" do
|
159
|
+
Plow::Dependencies.destroy_warnings
|
160
|
+
Plow::Dependencies.render_warnings
|
161
|
+
$stdout.string.should == ''
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
##################################################################################################
|
166
|
+
|
167
|
+
describe '.warn_at_exit' do
|
168
|
+
it 'should ensure Kernel#at_exit is invoked with a block' do
|
169
|
+
Plow::Dependencies.should_receive(:at_exit)
|
170
|
+
# TODO how to specify that #at_exit receives a block?
|
171
|
+
# maybe i can intercept the block, execute it and test the output?
|
172
|
+
Plow::Dependencies.warn_at_exit
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
data/spec/plow/errors_spec.rb
CHANGED
data/spec/plow/generator_spec.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
require
|
2
|
+
require 'spec_helper'
|
3
3
|
|
4
4
|
describe Plow::Generator do
|
5
5
|
|
@@ -50,8 +50,8 @@ describe Plow::Generator do
|
|
50
50
|
@generator.site_aliases.should == []
|
51
51
|
end
|
52
52
|
|
53
|
-
it "should set strategy to an instance of Plow::Strategy::UbuntuHardy
|
54
|
-
@generator.strategy.should be_an_instance_of(Plow::Strategy::UbuntuHardy
|
53
|
+
it "should set strategy to an instance of Plow::Strategy::UbuntuHardy" do
|
54
|
+
@generator.strategy.should be_an_instance_of(Plow::Strategy::UbuntuHardy)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -74,8 +74,8 @@ describe Plow::Generator do
|
|
74
74
|
@generator.site_aliases.should == ['apple.com']
|
75
75
|
end
|
76
76
|
|
77
|
-
it "should set strategy to an instance of Plow::Strategy::UbuntuHardy
|
78
|
-
@generator.strategy.should be_an_instance_of(Plow::Strategy::UbuntuHardy
|
77
|
+
it "should set strategy to an instance of Plow::Strategy::UbuntuHardy" do
|
78
|
+
@generator.strategy.should be_an_instance_of(Plow::Strategy::UbuntuHardy)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
@@ -91,7 +91,7 @@ describe Plow::Generator do
|
|
91
91
|
it "should execute the strategy when process is owned by root user" do
|
92
92
|
Process.stub!(:uid).and_return(0)
|
93
93
|
generator = Plow::Generator.new('steve', 'www.apple.com', 'apple.com')
|
94
|
-
generator.strategy.should_receive(:execute)
|
94
|
+
generator.strategy.should_receive(:execute!)
|
95
95
|
generator.run!
|
96
96
|
end
|
97
97
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
require
|
2
|
+
require 'spec_helper'
|
3
3
|
|
4
4
|
require 'tempfile'
|
5
5
|
|
6
|
-
describe Plow::Strategy::UbuntuHardy
|
6
|
+
describe Plow::Strategy::UbuntuHardy do
|
7
7
|
before(:each) do
|
8
8
|
@context = Plow::Generator.new('steve', 'www.apple.com', 'apple.com')
|
9
|
-
@strategy = Plow::Strategy::UbuntuHardy
|
9
|
+
@strategy = Plow::Strategy::UbuntuHardy.new(@context)
|
10
10
|
|
11
11
|
@parsed_users_fixture = [
|
12
12
|
{ name: "root", password: "x", id: 0, group_id: 0, info: "root", home_path: "/root", shell_path: "/bin/bash" },
|
@@ -60,7 +60,7 @@ describe Plow::Strategy::UbuntuHardy::UserHomeWebApp do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should set virtual host configuration template file path" do
|
63
|
-
expected = File.expand_path(File.dirname(__FILE__) + '
|
63
|
+
expected = File.expand_path(File.dirname(__FILE__) + '/../../../lib/plow/strategy/ubuntu_hardy/templates/apache2-vhost.conf')
|
64
64
|
@strategy.vhost_template_file_path.should == expected
|
65
65
|
end
|
66
66
|
end
|
@@ -122,10 +122,10 @@ describe Plow::Strategy::UbuntuHardy::UserHomeWebApp do
|
|
122
122
|
|
123
123
|
##################################################################################################
|
124
124
|
|
125
|
-
describe '#create_user (private)' do
|
125
|
+
describe '#create_user! (private)' do
|
126
126
|
it "should invoke a adduser as a system call" do
|
127
127
|
@strategy.should_receive(:shell).with("adduser steve")
|
128
|
-
@strategy.send(:create_user)
|
128
|
+
@strategy.send(:create_user!)
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
@@ -178,14 +178,14 @@ describe Plow::Strategy::UbuntuHardy::UserHomeWebApp do
|
|
178
178
|
|
179
179
|
##################################################################################################
|
180
180
|
|
181
|
-
describe '#create_user_home (private)' do
|
181
|
+
describe '#create_user_home! (private)' do
|
182
182
|
it "should create a user home with the correct ownership" do
|
183
183
|
@strategy.stub!(:user_home_path).and_return("/home/steve")
|
184
184
|
@strategy.should_receive(:shell).with(<<-COMMANDS)
|
185
|
-
|
186
|
-
|
185
|
+
mkdir /home/steve
|
186
|
+
chown steve:steve /home/steve
|
187
187
|
COMMANDS
|
188
|
-
@strategy.send(:create_user_home)
|
188
|
+
@strategy.send(:create_user_home!)
|
189
189
|
end
|
190
190
|
end
|
191
191
|
|
@@ -215,14 +215,14 @@ describe Plow::Strategy::UbuntuHardy::UserHomeWebApp do
|
|
215
215
|
|
216
216
|
##################################################################################################
|
217
217
|
|
218
|
-
describe '#create_sites_home (private)' do
|
218
|
+
describe '#create_sites_home! (private)' do
|
219
219
|
it "should create a sites home with the correct ownership" do
|
220
220
|
@strategy.stub!(:sites_home_path).and_return("/home/steve/sites")
|
221
221
|
@strategy.should_receive(:shell).with(<<-COMMANDS)
|
222
|
-
|
223
|
-
|
222
|
+
mkdir /home/steve/sites
|
223
|
+
chown steve:steve /home/steve/sites
|
224
224
|
COMMANDS
|
225
|
-
@strategy.send(:create_sites_home)
|
225
|
+
@strategy.send(:create_sites_home!)
|
226
226
|
end
|
227
227
|
end
|
228
228
|
|
@@ -252,49 +252,49 @@ describe Plow::Strategy::UbuntuHardy::UserHomeWebApp do
|
|
252
252
|
|
253
253
|
##################################################################################################
|
254
254
|
|
255
|
-
describe '#create_app_root (private)' do
|
255
|
+
describe '#create_app_root! (private)' do
|
256
256
|
it "should create an application home correctly" do
|
257
257
|
@strategy.stub!(:app_root_path).and_return('/home/steve/sites/www.apple.com')
|
258
258
|
@strategy.should_receive(:shell).with(<<-COMMANDS)
|
259
|
-
|
260
|
-
|
259
|
+
mkdir /home/steve/sites/www.apple.com
|
260
|
+
chown steve:steve /home/steve/sites/www.apple.com
|
261
261
|
COMMANDS
|
262
|
-
@strategy.send(:create_app_root)
|
262
|
+
@strategy.send(:create_app_root!)
|
263
263
|
end
|
264
264
|
end
|
265
265
|
|
266
266
|
##################################################################################################
|
267
267
|
|
268
|
-
describe '#create_app_public (private)' do
|
268
|
+
describe '#create_app_public! (private)' do
|
269
269
|
it "should build an application's public files correctly" do
|
270
270
|
@strategy.stub!(:app_public_path).and_return('/home/steve/sites/www.apple.com/public')
|
271
271
|
@strategy.should_receive(:shell).with(<<-COMMANDS)
|
272
|
-
|
273
|
-
|
274
|
-
|
272
|
+
mkdir /home/steve/sites/www.apple.com/public
|
273
|
+
touch /home/steve/sites/www.apple.com/public/index.html
|
274
|
+
chown -R steve:steve /home/steve/sites/www.apple.com/public
|
275
275
|
COMMANDS
|
276
|
-
@strategy.send(:create_app_public)
|
276
|
+
@strategy.send(:create_app_public!)
|
277
277
|
end
|
278
278
|
end
|
279
279
|
|
280
280
|
##################################################################################################
|
281
281
|
|
282
|
-
describe '#create_app_logs (private)' do
|
282
|
+
describe '#create_app_logs! (private)' do
|
283
283
|
it "should build an application's log files correctly" do
|
284
284
|
@strategy.stub!(:app_log_path).and_return('/home/steve/sites/www.apple.com/log')
|
285
285
|
@strategy.should_receive(:shell).with(<<-COMMANDS)
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
286
|
+
mkdir /home/steve/sites/www.apple.com/log
|
287
|
+
mkdir /home/steve/sites/www.apple.com/log/apache2
|
288
|
+
chmod 750 /home/steve/sites/www.apple.com/log/apache2
|
289
|
+
|
290
|
+
touch /home/steve/sites/www.apple.com/log/apache2/access.log
|
291
|
+
touch /home/steve/sites/www.apple.com/log/apache2/error.log
|
292
|
+
|
293
|
+
chmod 640 /home/steve/sites/www.apple.com/log/apache2/*.log
|
294
|
+
chown -R steve:steve /home/steve/sites/www.apple.com/log
|
295
|
+
chown root -R /home/steve/sites/www.apple.com/log/apache2
|
296
296
|
COMMANDS
|
297
|
-
@strategy.send(:create_app_logs)
|
297
|
+
@strategy.send(:create_app_logs!)
|
298
298
|
end
|
299
299
|
end
|
300
300
|
|
@@ -314,7 +314,7 @@ describe Plow::Strategy::UbuntuHardy::UserHomeWebApp do
|
|
314
314
|
|
315
315
|
##################################################################################################
|
316
316
|
|
317
|
-
describe '#create_vhost_config (private)' do
|
317
|
+
describe '#create_vhost_config! (private)' do
|
318
318
|
before(:each) do
|
319
319
|
@temp_file = Tempfile.new('generate_vhost_config')
|
320
320
|
@strategy.stub!(:vhost_file_path).and_return(@temp_file.path)
|
@@ -324,7 +324,7 @@ describe Plow::Strategy::UbuntuHardy::UserHomeWebApp do
|
|
324
324
|
|
325
325
|
it "should create a vhost config file from template file without site aliases" do
|
326
326
|
@context.stub!(:site_aliases).and_return([])
|
327
|
-
@strategy.send(:create_vhost_config)
|
327
|
+
@strategy.send(:create_vhost_config!)
|
328
328
|
|
329
329
|
File.read(@temp_file.path).should == <<-CONFIG
|
330
330
|
|
@@ -343,7 +343,7 @@ describe Plow::Strategy::UbuntuHardy::UserHomeWebApp do
|
|
343
343
|
end
|
344
344
|
|
345
345
|
it "should create a vhost config file from template file with site aliases" do
|
346
|
-
@strategy.send(:create_vhost_config)
|
346
|
+
@strategy.send(:create_vhost_config!)
|
347
347
|
File.read(@temp_file.path).should == <<-CONFIG
|
348
348
|
|
349
349
|
<VirtualHost *:80>
|
@@ -365,19 +365,19 @@ describe Plow::Strategy::UbuntuHardy::UserHomeWebApp do
|
|
365
365
|
|
366
366
|
##################################################################################################
|
367
367
|
|
368
|
-
describe '#install_vhost_config (private)' do
|
368
|
+
describe '#install_vhost_config! (private)' do
|
369
369
|
it "should enable vhost and restart apache2" do
|
370
370
|
@strategy.should_receive(:shell).with(<<-COMMANDS)
|
371
|
-
|
372
|
-
|
371
|
+
a2ensite www.apple.com.conf > /dev/null
|
372
|
+
apache2ctl graceful
|
373
373
|
COMMANDS
|
374
|
-
@strategy.send(:install_vhost_config)
|
374
|
+
@strategy.send(:install_vhost_config!)
|
375
375
|
end
|
376
376
|
end
|
377
377
|
|
378
378
|
##################################################################################################
|
379
379
|
|
380
|
-
describe '#execute' do
|
380
|
+
describe '#execute!' do
|
381
381
|
before(:each) do
|
382
382
|
@strategy.stub!(:user_exists?).and_return(false)
|
383
383
|
@strategy.stub!(:user_home_exists?).and_return(true)
|
@@ -397,16 +397,16 @@ describe Plow::Strategy::UbuntuHardy::UserHomeWebApp do
|
|
397
397
|
end
|
398
398
|
|
399
399
|
it "should run the default process" do
|
400
|
-
@strategy.should_receive(:create_user)
|
401
|
-
@strategy.should_not_receive(:create_user_home)
|
402
|
-
@strategy.should_receive(:create_sites_home)
|
403
|
-
@strategy.should_receive(:create_app_root)
|
404
|
-
@strategy.should_receive(:create_app_public)
|
405
|
-
@strategy.should_receive(:create_app_logs)
|
406
|
-
@strategy.should_receive(:create_vhost_config)
|
407
|
-
@strategy.should_receive(:install_vhost_config)
|
400
|
+
@strategy.should_receive(:create_user!)
|
401
|
+
@strategy.should_not_receive(:create_user_home!)
|
402
|
+
@strategy.should_receive(:create_sites_home!)
|
403
|
+
@strategy.should_receive(:create_app_root!)
|
404
|
+
@strategy.should_receive(:create_app_public!)
|
405
|
+
@strategy.should_receive(:create_app_logs!)
|
406
|
+
@strategy.should_receive(:create_vhost_config!)
|
407
|
+
@strategy.should_receive(:install_vhost_config!)
|
408
408
|
|
409
|
-
@strategy.execute
|
409
|
+
@strategy.execute!
|
410
410
|
|
411
411
|
@strategy.app_public_path.should == '/home/steve/sites/www.apple.com/public'
|
412
412
|
@strategy.app_log_path.should == '/home/steve/sites/www.apple.com/log'
|
@@ -427,15 +427,15 @@ describe Plow::Strategy::UbuntuHardy::UserHomeWebApp do
|
|
427
427
|
@strategy.stub!(:user_exists?).and_return(true)
|
428
428
|
|
429
429
|
@strategy.should_not_receive(:create_user)
|
430
|
-
@strategy.should_not_receive(:create_user_home)
|
431
|
-
@strategy.should_receive(:create_sites_home)
|
432
|
-
@strategy.should_receive(:create_app_root)
|
433
|
-
@strategy.should_receive(:create_app_public)
|
434
|
-
@strategy.should_receive(:create_app_logs)
|
435
|
-
@strategy.should_receive(:create_vhost_config)
|
436
|
-
@strategy.should_receive(:install_vhost_config)
|
430
|
+
@strategy.should_not_receive(:create_user_home!)
|
431
|
+
@strategy.should_receive(:create_sites_home!)
|
432
|
+
@strategy.should_receive(:create_app_root!)
|
433
|
+
@strategy.should_receive(:create_app_public!)
|
434
|
+
@strategy.should_receive(:create_app_logs!)
|
435
|
+
@strategy.should_receive(:create_vhost_config!)
|
436
|
+
@strategy.should_receive(:install_vhost_config!)
|
437
437
|
|
438
|
-
@strategy.execute
|
438
|
+
@strategy.execute!
|
439
439
|
|
440
440
|
@strategy.app_public_path.should == '/home/steve/sites/www.apple.com/public'
|
441
441
|
@strategy.app_log_path.should == '/home/steve/sites/www.apple.com/log'
|
@@ -455,16 +455,16 @@ describe Plow::Strategy::UbuntuHardy::UserHomeWebApp do
|
|
455
455
|
it "should run the missing user home process" do
|
456
456
|
@strategy.stub!(:user_home_exists?).and_return(false)
|
457
457
|
|
458
|
-
@strategy.should_receive(:create_user)
|
459
|
-
@strategy.should_receive(:create_user_home)
|
460
|
-
@strategy.should_receive(:create_sites_home)
|
461
|
-
@strategy.should_receive(:create_app_root)
|
462
|
-
@strategy.should_receive(:create_app_public)
|
463
|
-
@strategy.should_receive(:create_app_logs)
|
464
|
-
@strategy.should_receive(:create_vhost_config)
|
465
|
-
@strategy.should_receive(:install_vhost_config)
|
458
|
+
@strategy.should_receive(:create_user!)
|
459
|
+
@strategy.should_receive(:create_user_home!)
|
460
|
+
@strategy.should_receive(:create_sites_home!)
|
461
|
+
@strategy.should_receive(:create_app_root!)
|
462
|
+
@strategy.should_receive(:create_app_public!)
|
463
|
+
@strategy.should_receive(:create_app_logs!)
|
464
|
+
@strategy.should_receive(:create_vhost_config!)
|
465
|
+
@strategy.should_receive(:install_vhost_config!)
|
466
466
|
|
467
|
-
@strategy.execute
|
467
|
+
@strategy.execute!
|
468
468
|
|
469
469
|
@strategy.app_public_path.should == '/home/steve/sites/www.apple.com/public'
|
470
470
|
@strategy.app_log_path.should == '/home/steve/sites/www.apple.com/log'
|
@@ -484,16 +484,16 @@ describe Plow::Strategy::UbuntuHardy::UserHomeWebApp do
|
|
484
484
|
it "should run the existing sites home process" do
|
485
485
|
@strategy.stub!(:sites_home_exists?).and_return(true)
|
486
486
|
|
487
|
-
@strategy.should_receive(:create_user)
|
488
|
-
@strategy.should_not_receive(:create_user_home)
|
489
|
-
@strategy.should_not_receive(:create_sites_home)
|
490
|
-
@strategy.should_receive(:create_app_root)
|
491
|
-
@strategy.should_receive(:create_app_public)
|
492
|
-
@strategy.should_receive(:create_app_logs)
|
493
|
-
@strategy.should_receive(:create_vhost_config)
|
494
|
-
@strategy.should_receive(:install_vhost_config)
|
487
|
+
@strategy.should_receive(:create_user!)
|
488
|
+
@strategy.should_not_receive(:create_user_home!)
|
489
|
+
@strategy.should_not_receive(:create_sites_home!)
|
490
|
+
@strategy.should_receive(:create_app_root!)
|
491
|
+
@strategy.should_receive(:create_app_public!)
|
492
|
+
@strategy.should_receive(:create_app_logs!)
|
493
|
+
@strategy.should_receive(:create_vhost_config!)
|
494
|
+
@strategy.should_receive(:install_vhost_config!)
|
495
495
|
|
496
|
-
@strategy.execute
|
496
|
+
@strategy.execute!
|
497
497
|
|
498
498
|
@strategy.app_public_path.should == '/home/steve/sites/www.apple.com/public'
|
499
499
|
@strategy.app_log_path.should == '/home/steve/sites/www.apple.com/log'
|
@@ -513,16 +513,16 @@ describe Plow::Strategy::UbuntuHardy::UserHomeWebApp do
|
|
513
513
|
it "should run the existing app root process" do
|
514
514
|
@strategy.stub!(:app_root_exists?).and_return(true)
|
515
515
|
|
516
|
-
@strategy.should_receive(:create_user)
|
517
|
-
@strategy.should_not_receive(:create_user_home)
|
518
|
-
@strategy.should_receive(:create_sites_home)
|
519
|
-
@strategy.should_not_receive(:create_app_root)
|
520
|
-
@strategy.should_not_receive(:create_app_public)
|
521
|
-
@strategy.should_not_receive(:create_app_logs)
|
522
|
-
@strategy.should_not_receive(:create_vhost_config)
|
523
|
-
@strategy.should_not_receive(:install_vhost_config)
|
516
|
+
@strategy.should_receive(:create_user!)
|
517
|
+
@strategy.should_not_receive(:create_user_home!)
|
518
|
+
@strategy.should_receive(:create_sites_home!)
|
519
|
+
@strategy.should_not_receive(:create_app_root!)
|
520
|
+
@strategy.should_not_receive(:create_app_public!)
|
521
|
+
@strategy.should_not_receive(:create_app_logs!)
|
522
|
+
@strategy.should_not_receive(:create_vhost_config!)
|
523
|
+
@strategy.should_not_receive(:install_vhost_config!)
|
524
524
|
|
525
|
-
lambda { @strategy.execute }.should raise_error(Plow::AppRootAlreadyExistsError, '/home/steve/sites/www.apple.com')
|
525
|
+
lambda { @strategy.execute! }.should raise_error(Plow::AppRootAlreadyExistsError, '/home/steve/sites/www.apple.com')
|
526
526
|
|
527
527
|
$stdout.string.should == <<-OUTPUT
|
528
528
|
==> creating steve user
|
@@ -534,16 +534,16 @@ describe Plow::Strategy::UbuntuHardy::UserHomeWebApp do
|
|
534
534
|
it "should run the existing vhost config process" do
|
535
535
|
@strategy.stub!(:vhost_config_exists?).and_return(true)
|
536
536
|
|
537
|
-
@strategy.should_receive(:create_user)
|
538
|
-
@strategy.should_not_receive(:create_user_home)
|
539
|
-
@strategy.should_receive(:create_sites_home)
|
540
|
-
@strategy.should_receive(:create_app_root)
|
541
|
-
@strategy.should_receive(:create_app_public)
|
542
|
-
@strategy.should_receive(:create_app_logs)
|
543
|
-
@strategy.should_not_receive(:create_vhost_config)
|
544
|
-
@strategy.should_not_receive(:install_vhost_config)
|
537
|
+
@strategy.should_receive(:create_user!)
|
538
|
+
@strategy.should_not_receive(:create_user_home!)
|
539
|
+
@strategy.should_receive(:create_sites_home!)
|
540
|
+
@strategy.should_receive(:create_app_root!)
|
541
|
+
@strategy.should_receive(:create_app_public!)
|
542
|
+
@strategy.should_receive(:create_app_logs!)
|
543
|
+
@strategy.should_not_receive(:create_vhost_config!)
|
544
|
+
@strategy.should_not_receive(:install_vhost_config!)
|
545
545
|
|
546
|
-
lambda { @strategy.execute }.should raise_error(Plow::ConfigFileAlreadyExistsError, '/etc/apache2/sites-available/www.apple.com.conf')
|
546
|
+
lambda { @strategy.execute! }.should raise_error(Plow::ConfigFileAlreadyExistsError, '/etc/apache2/sites-available/www.apple.com.conf')
|
547
547
|
|
548
548
|
@strategy.app_public_path.should == '/home/steve/sites/www.apple.com/public'
|
549
549
|
@strategy.app_log_path.should == '/home/steve/sites/www.apple.com/log'
|
data/spec/plow_spec.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
require
|
2
|
+
require 'spec_helper'
|
3
3
|
|
4
4
|
describe "Plow" do
|
5
5
|
describe "version synchronizing" do
|
6
6
|
before(:each) do
|
7
|
-
@expected = "
|
7
|
+
@expected = "1.0.0"
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should be correct for Plow::VERSION" do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,29 +1,5 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
unless $LOAD_PATH.include?(File.dirname(__FILE__))
|
4
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
5
|
-
end
|
6
|
-
|
7
|
-
unless $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__) + '/../lib'))
|
8
|
-
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
|
9
|
-
end
|
10
|
-
|
11
|
-
begin
|
12
|
-
require 'spec'
|
13
|
-
require 'spec/autorun'
|
14
|
-
rescue LoadError
|
15
|
-
abort <<-ERROR
|
16
|
-
Unexpected LoadError exception caught in #{__FILE__} on #{__LINE__}
|
17
|
-
|
18
|
-
This file depends on the rspec library, which is not available.
|
19
|
-
You may install the library via rubygems with: sudo gem install rspec
|
20
|
-
ERROR
|
21
|
-
end
|
22
|
-
|
23
3
|
require 'plow'
|
24
4
|
|
25
5
|
FIXTURES_PATH = File.dirname(__FILE__) + '/fixtures'
|
26
|
-
|
27
|
-
Spec::Runner.configure do |config|
|
28
|
-
|
29
|
-
end
|