stub_server 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/stub_server.rb +15 -2
- data/lib/stub_server/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 155a93e95326f0252760f49f230476e65edd675204748b2860c3da17b2455a85
|
4
|
+
data.tar.gz: 67f52eb9bd2afb995b0e13864c6b91a45848628d18c89db2328b4236e170879d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e544936dcb928d37fe10e9aa5ec5810a9c2f67e2978a64659d948d4fa19ff81f469d86bfee1f2a4070eb11481fca1020ad3d8f1e6dd6b052380b8401f286e785
|
7
|
+
data.tar.gz: '0438ec13914e39e7632e7d4a60c30258425587460d0614a8396e13c6f119f825a68580c97ceffc1464b95ab1cbf604cfbdc0d9940cef667db0fe8a6c835031a5'
|
data/lib/stub_server.rb
CHANGED
@@ -18,10 +18,12 @@ class StubServer
|
|
18
18
|
@json = json
|
19
19
|
@webrick = webrick
|
20
20
|
@started = false
|
21
|
+
@server = nil
|
22
|
+
@thread = nil
|
21
23
|
end
|
22
24
|
|
23
25
|
def boot
|
24
|
-
Thread.new do
|
26
|
+
@thread = Thread.new do
|
25
27
|
options = {
|
26
28
|
Port: @port,
|
27
29
|
Logger: WEBrick::Log.new("/dev/null"),
|
@@ -65,6 +67,17 @@ class StubServer
|
|
65
67
|
end
|
66
68
|
|
67
69
|
def shutdown
|
68
|
-
@server
|
70
|
+
@server&.shutdown
|
71
|
+
@thread.join # need to wait here and cannot simpliy kill or webbrick keeps running
|
72
|
+
|
73
|
+
# TimeoutHandler keeps running forever which breaks tests that assert no extra threads
|
74
|
+
# we should only stop it if it is empty, otherwise we are still waiting for other servers
|
75
|
+
# ideally we'd use WEBrick::Utils::TimeoutHandler::TimeoutMutex.synchronize to avoid race conditions,
|
76
|
+
# but that is also used in .terminate and would lead to deadlocks ...
|
77
|
+
# TODO: open ruby issue for race-condition free terminate_if_empty
|
78
|
+
return if RUBY_VERSION < "2.4.0"
|
79
|
+
if WEBrick::Utils::TimeoutHandler.instance.instance_variable_get(:@timeout_info).empty?
|
80
|
+
WEBrick::Utils::TimeoutHandler.terminate
|
81
|
+
end
|
69
82
|
end
|
70
83
|
end
|
data/lib/stub_server/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stub_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -45,7 +45,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 2.
|
48
|
+
version: 2.3.0
|
49
49
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
@@ -53,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
53
|
version: '0'
|
54
54
|
requirements: []
|
55
55
|
rubyforge_project:
|
56
|
-
rubygems_version: 2.
|
56
|
+
rubygems_version: 2.7.6
|
57
57
|
signing_key:
|
58
58
|
specification_version: 4
|
59
59
|
summary: Boot up a real server to serve testing replies
|