http_server_manager 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/http_server_manager/rake/server_tasks.rb +5 -0
- data/lib/http_server_manager/server.rb +5 -0
- data/lib/http_server_manager/version.rb +1 -1
- data/spec/lib/http_server_manager/rake/server_tasks_spec.rb +66 -0
- data/spec/lib/http_server_manager/server_integration_spec.rb +1 -1
- data/spec/lib/http_server_manager/server_spec.rb +29 -0
- metadata +7 -5
- data/spec/lib/http_server_manager/rake/server_tasks_integration_spec.rb +0 -61
@@ -17,6 +17,11 @@ module HttpServerManager
|
|
17
17
|
server.stop!
|
18
18
|
end
|
19
19
|
|
20
|
+
desc "Restart an potentially running #{server.name}"
|
21
|
+
task :restart do
|
22
|
+
server.restart!
|
23
|
+
end
|
24
|
+
|
20
25
|
desc "Displays the status of a #{server.name} process"
|
21
26
|
task :status do
|
22
27
|
puts "#{server.name} is #{server.status}"
|
@@ -0,0 +1,66 @@
|
|
1
|
+
describe HttpServerManager::Rake::ServerTasks do
|
2
|
+
include_context "managed http server integration utilities"
|
3
|
+
include ::Rake::DSL
|
4
|
+
|
5
|
+
let(:task_namespace) { :test_server_namespace }
|
6
|
+
let(:server) { double(HttpServerManager::Server, name: "test_server") }
|
7
|
+
|
8
|
+
let(:server_tasks) { HttpServerManager::Rake::ServerTasks.new(server) }
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
namespace task_namespace do
|
12
|
+
server_tasks
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
after(:each) { Rake.application.tasks_in_scope([task_namespace]).each(&:clear) }
|
17
|
+
|
18
|
+
describe "start task" do
|
19
|
+
|
20
|
+
let(:task) { ::Rake::Task["#{task_namespace}:start"] }
|
21
|
+
|
22
|
+
it "should start the server" do
|
23
|
+
server.should_receive(:start!)
|
24
|
+
|
25
|
+
task.execute
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "stop task" do
|
31
|
+
|
32
|
+
let(:task) { ::Rake::Task["#{task_namespace}:stop"] }
|
33
|
+
|
34
|
+
it "should stop the server" do
|
35
|
+
server.should_receive(:stop!)
|
36
|
+
|
37
|
+
task.execute
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "restart task" do
|
43
|
+
|
44
|
+
let(:task) { ::Rake::Task["#{task_namespace}:restart"] }
|
45
|
+
|
46
|
+
it "should restart the server" do
|
47
|
+
server.should_receive(:restart!)
|
48
|
+
task.execute
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "status task" do
|
54
|
+
|
55
|
+
let(:task) { ::Rake::Task["#{task_namespace}:status"] }
|
56
|
+
|
57
|
+
it "should write the server name and it's status to stdout" do
|
58
|
+
server.stub!(:status).and_return("stopped")
|
59
|
+
server_tasks.should_receive(:puts).with("test_server is stopped")
|
60
|
+
|
61
|
+
task.execute
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
describe HttpServerManager::Server do
|
2
|
+
|
3
|
+
class HttpServerManager::TestableServer < HttpServerManager::Server
|
4
|
+
|
5
|
+
def start_command
|
6
|
+
"some command"
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:server) { HttpServerManager::TestableServer.new(name: "Test Server", port: 8888) }
|
12
|
+
|
13
|
+
before(:each) do
|
14
|
+
server.stub!(:start!)
|
15
|
+
server.stub!(:stop!)
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#restart!" do
|
19
|
+
|
20
|
+
it "should first stop the server and then start the server" do
|
21
|
+
server.should_receive(:stop!).ordered
|
22
|
+
server.should_receive(:start!).ordered
|
23
|
+
|
24
|
+
server.restart!
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http_server_manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -155,8 +155,9 @@ files:
|
|
155
155
|
- ./spec/support/http_server_manager/test/server_integration_utilities_spec_context.rb
|
156
156
|
- ./spec/support/http_server_manager/test/silent_logger.rb
|
157
157
|
- ./spec/support/http_server_manager/test_support.rb
|
158
|
-
- ./spec/lib/http_server_manager/rake/
|
158
|
+
- ./spec/lib/http_server_manager/rake/server_tasks_spec.rb
|
159
159
|
- ./spec/lib/http_server_manager/server_integration_spec.rb
|
160
|
+
- ./spec/lib/http_server_manager/server_spec.rb
|
160
161
|
- ./spec/lib/http_server_manager/stdout_logger_spec.rb
|
161
162
|
- ./spec/lib/http_server_manager_spec.rb
|
162
163
|
- ./spec/spec_helper.rb
|
@@ -182,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
183
|
version: '0'
|
183
184
|
segments:
|
184
185
|
- 0
|
185
|
-
hash:
|
186
|
+
hash: 4335751342114545117
|
186
187
|
requirements: []
|
187
188
|
rubyforge_project: http_server_manager
|
188
189
|
rubygems_version: 1.8.25
|
@@ -190,8 +191,9 @@ signing_key:
|
|
190
191
|
specification_version: 3
|
191
192
|
summary: Manages the lifecycle of HTTP server processes
|
192
193
|
test_files:
|
193
|
-
- ./spec/lib/http_server_manager/rake/
|
194
|
+
- ./spec/lib/http_server_manager/rake/server_tasks_spec.rb
|
194
195
|
- ./spec/lib/http_server_manager/server_integration_spec.rb
|
196
|
+
- ./spec/lib/http_server_manager/server_spec.rb
|
195
197
|
- ./spec/lib/http_server_manager/stdout_logger_spec.rb
|
196
198
|
- ./spec/lib/http_server_manager_spec.rb
|
197
199
|
- ./spec/spec_helper.rb
|
@@ -1,61 +0,0 @@
|
|
1
|
-
describe HttpServerManager::Rake::ServerTasks do
|
2
|
-
include_context "managed http server integration utilities"
|
3
|
-
include ::Rake::DSL
|
4
|
-
|
5
|
-
before(:all) do
|
6
|
-
namespace :rack_server do
|
7
|
-
server_tasks
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
describe "start task" do
|
12
|
-
|
13
|
-
let(:task) { ::Rake::Task["rack_server:start"] }
|
14
|
-
|
15
|
-
after(:each) { force_stop! }
|
16
|
-
|
17
|
-
it "should start a stopped server" do
|
18
|
-
task.execute
|
19
|
-
|
20
|
-
wait_until_started!
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
describe "stop task" do
|
26
|
-
|
27
|
-
let(:task) { ::Rake::Task["rack_server:stop"] }
|
28
|
-
|
29
|
-
before(:each) { force_start! }
|
30
|
-
|
31
|
-
after(:each) { force_stop! } # Ensure server has completely stopped
|
32
|
-
|
33
|
-
it "should stop a started server" do
|
34
|
-
task.execute
|
35
|
-
|
36
|
-
wait_until_stopped!
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
describe "status task" do
|
42
|
-
|
43
|
-
let(:task) { ::Rake::Task["rack_server:status"] }
|
44
|
-
|
45
|
-
it "should write the server name and it's status to stdout" do
|
46
|
-
server_tasks.should_receive(:puts).with("rack_server is stopped")
|
47
|
-
|
48
|
-
task.execute
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
def server_tasks
|
54
|
-
@server_tasks ||= HttpServerManager::Rake::ServerTasks.new(server)
|
55
|
-
end
|
56
|
-
|
57
|
-
def server
|
58
|
-
@server ||= RackServer.new(port: 4001)
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|