http_server_manager 0.4.2 → 0.4.3
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/lib/http_server_manager/server.rb +1 -1
- data/lib/http_server_manager/version.rb +1 -1
- data/spec/lib/http_server_manager/server_spec.rb +64 -4
- data/spec/lib/http_server_manager/test/server_integration_examples_spec.rb +7 -0
- data/spec/support/http_server_manager/test/server_integration_examples.rb +20 -0
- data/spec/support/http_server_manager/test/silent_logger.rb +1 -1
- data/spec/support/http_server_manager/test_support.rb +1 -0
- metadata +6 -2
@@ -8,7 +8,7 @@ module HttpServerManager
|
|
8
8
|
@name = options[:name]
|
9
9
|
@host = options[:host]
|
10
10
|
@port = options[:port]
|
11
|
-
@timeout_in_seconds = options[:timeout_in_seconds] || 20
|
11
|
+
@timeout_in_seconds = options[:timeout_in_seconds] || (ENV["timeout"] ? ENV["timeout"].to_i : 20)
|
12
12
|
@deletable_artifacts = [pid_file_path]
|
13
13
|
end
|
14
14
|
|
@@ -8,15 +8,75 @@ describe HttpServerManager::Server do
|
|
8
8
|
|
9
9
|
end
|
10
10
|
|
11
|
-
let(:
|
11
|
+
let(:server_options) { { name: "Test Server", host: "localhost", port: 8888 } }
|
12
|
+
|
13
|
+
let(:server) { HttpServerManager::TestableServer.new(server_options) }
|
14
|
+
|
15
|
+
describe "#start!" do
|
16
|
+
|
17
|
+
before(:each) { Wait.stub(:until_true!) }
|
18
|
+
|
19
|
+
context "when the server is not running" do
|
20
|
+
|
21
|
+
let(:env_timeout) { nil }
|
22
|
+
|
23
|
+
before(:each) do
|
24
|
+
ENV.stub(:[]).with("timeout").and_return(env_timeout)
|
25
|
+
server.stub(:running?).and_return(false)
|
26
|
+
Process.stub(:spawn)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should start the server by spawning a process that executes the start command" do
|
30
|
+
Process.should_receive(:spawn).with("some command", anything).and_return(888)
|
31
|
+
|
32
|
+
server.start!
|
33
|
+
end
|
34
|
+
|
35
|
+
context "when a timeout is provided as a constructor argument" do
|
36
|
+
|
37
|
+
let(:server_options) { { name: "Test Server", host: "localhost", port: 8888, timeout_in_seconds: 3 } }
|
38
|
+
|
39
|
+
it "should wait for the specified amount of time in seconds for the server to start" do
|
40
|
+
Wait.should_receive(:until_true!).with(anything, timeout_in_seconds: 3)
|
41
|
+
|
42
|
+
server.start!
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
context "when a timeout is provided as an environment variable" do
|
48
|
+
|
49
|
+
let(:env_timeout) { "8" }
|
50
|
+
|
51
|
+
it "should wait for the specified amount of time in seconds for the server to start" do
|
52
|
+
Wait.should_receive(:until_true!).with(anything, timeout_in_seconds: 8)
|
53
|
+
|
54
|
+
server.start!
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
context "when no timeout is provided" do
|
60
|
+
|
61
|
+
it "should wait 20 seconds for the server to start" do
|
62
|
+
Wait.should_receive(:until_true!).with(anything, timeout_in_seconds: 20)
|
63
|
+
|
64
|
+
server.start!
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
12
70
|
|
13
|
-
before(:each) do
|
14
|
-
server.stub(:start!)
|
15
|
-
server.stub(:stop!)
|
16
71
|
end
|
17
72
|
|
18
73
|
describe "#restart!" do
|
19
74
|
|
75
|
+
before(:each) do
|
76
|
+
server.stub(:start!)
|
77
|
+
server.stub(:stop!)
|
78
|
+
end
|
79
|
+
|
20
80
|
it "should first stop the server and then start the server" do
|
21
81
|
server.should_receive(:stop!).ordered
|
22
82
|
server.should_receive(:start!).ordered
|
@@ -0,0 +1,20 @@
|
|
1
|
+
shared_examples_for "a managed http server" do
|
2
|
+
include_context "managed http server integration utilities"
|
3
|
+
|
4
|
+
it "should be a HttpServerManager::Server" do
|
5
|
+
server.should be_an(HttpServerManager::Server)
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#start!" do
|
9
|
+
|
10
|
+
after(:each) { force_stop! }
|
11
|
+
|
12
|
+
it "should start the server via the provided command" do
|
13
|
+
server.start!
|
14
|
+
|
15
|
+
wait_until_started!
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
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.
|
4
|
+
version: 0.4.3
|
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-11-
|
12
|
+
date: 2013-11-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -151,6 +151,7 @@ files:
|
|
151
151
|
- ./lib/http_server_manager/stdout_logger.rb
|
152
152
|
- ./lib/http_server_manager/version.rb
|
153
153
|
- ./lib/http_server_manager.rb
|
154
|
+
- ./spec/support/http_server_manager/test/server_integration_examples.rb
|
154
155
|
- ./spec/support/http_server_manager/test/server_integration_utilities.rb
|
155
156
|
- ./spec/support/http_server_manager/test/server_integration_utilities_spec_context.rb
|
156
157
|
- ./spec/support/http_server_manager/test/silent_logger.rb
|
@@ -159,6 +160,7 @@ files:
|
|
159
160
|
- ./spec/lib/http_server_manager/server_integration_spec.rb
|
160
161
|
- ./spec/lib/http_server_manager/server_spec.rb
|
161
162
|
- ./spec/lib/http_server_manager/stdout_logger_spec.rb
|
163
|
+
- ./spec/lib/http_server_manager/test/server_integration_examples_spec.rb
|
162
164
|
- ./spec/lib/http_server_manager_spec.rb
|
163
165
|
- ./spec/spec_helper.rb
|
164
166
|
homepage: http://github.com/MYOB-Technology/http_server_manager
|
@@ -192,8 +194,10 @@ test_files:
|
|
192
194
|
- ./spec/lib/http_server_manager/server_integration_spec.rb
|
193
195
|
- ./spec/lib/http_server_manager/server_spec.rb
|
194
196
|
- ./spec/lib/http_server_manager/stdout_logger_spec.rb
|
197
|
+
- ./spec/lib/http_server_manager/test/server_integration_examples_spec.rb
|
195
198
|
- ./spec/lib/http_server_manager_spec.rb
|
196
199
|
- ./spec/spec_helper.rb
|
200
|
+
- ./spec/support/http_server_manager/test/server_integration_examples.rb
|
197
201
|
- ./spec/support/http_server_manager/test/server_integration_utilities.rb
|
198
202
|
- ./spec/support/http_server_manager/test/server_integration_utilities_spec_context.rb
|
199
203
|
- ./spec/support/http_server_manager/test/silent_logger.rb
|