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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 58a7b20389059c4240beb2c6b86528fde3a5ce8a
4
- data.tar.gz: 505257acb6a2c64044826aa221d475126bf2bb66
2
+ SHA256:
3
+ metadata.gz: 155a93e95326f0252760f49f230476e65edd675204748b2860c3da17b2455a85
4
+ data.tar.gz: 67f52eb9bd2afb995b0e13864c6b91a45848628d18c89db2328b4236e170879d
5
5
  SHA512:
6
- metadata.gz: ad16c50a613b9ef98ef7b1f6ab1cbe3a2a5dac5013fe8102e2eece17db68c1fac4fa137c72152ce06d9c29b8b70e8764c8efd584e3f3602118fa3fcb48e4a69b
7
- data.tar.gz: 58a32d391e31c2d89da28a9ab3860f08787dca21fe7bc90691078a78937e5d5c450ac294af0411700d4fa4d103a8d6be51f8f2502d4ffcbcdf2b408fdad1e9d5
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.shutdown if @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
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  class StubServer
3
- VERSION = "0.2.1"
3
+ VERSION = "0.3.0"
4
4
  end
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.2.1
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: 2016-12-05 00:00:00.000000000 Z
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.0.0
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.5.1
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