rspec-httpd 0.3.5 → 0.3.6
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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/rspec/httpd.rb +3 -3
- data/lib/rspec/httpd/config.rb +1 -1
- data/lib/rspec/httpd/server.rb +16 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f127a5abd4a8ac754c24cd3a58360ab60e749ca847fa65d1859ca3b9a4fd5e54
|
4
|
+
data.tar.gz: 6b76d26b499b3e411e36efee597ca6406b1f52f82b24c5163a848b89c86712f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcc7057d59576c750558e3cc3bc39fc075bad75722f82f6d14a10fa73cf89b274a6a18ca3b09316f081069e826ae6987d7e790328b725616cac7b24fe46a3910
|
7
|
+
data.tar.gz: 1fc2cd38d2387ba5f78ab5f6cc8ed3d1ff5ea2c47f44edf5a03b6976ac7867baebe9573154ab96cbb1b66357820208f27cc0b85b083a199e766d7691ce02b24f
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.6
|
data/lib/rspec/httpd.rb
CHANGED
@@ -84,9 +84,9 @@ module RSpec::Httpd
|
|
84
84
|
|
85
85
|
if response.status >= 400
|
86
86
|
error_message += <<~MSG
|
87
|
-
|
88
|
-
|
89
|
-
|
87
|
+
---- response.body ----------------------------------------------------
|
88
|
+
#{response.body}
|
89
|
+
-----------------------------------------------------------------------
|
90
90
|
MSG
|
91
91
|
end
|
92
92
|
|
data/lib/rspec/httpd/config.rb
CHANGED
data/lib/rspec/httpd/server.rb
CHANGED
@@ -37,24 +37,32 @@ module RSpec::Httpd
|
|
37
37
|
# You can use this method to retrieve a client connection to a server
|
38
38
|
# specified via host:, port:, and, optionally, a command.
|
39
39
|
def start!(host: "0.0.0.0", port:, command:, logger: nil)
|
40
|
+
puts "start! command: #{command.inspect}"
|
40
41
|
@servers ||= {}
|
41
|
-
@servers[[host, port, command]] ||= do_start(host, port, command)
|
42
|
+
@servers[[host, port, command]] ||= command ? do_start(host, port, command) : check_server(host, port)
|
42
43
|
@logger = logger if logger
|
43
44
|
end
|
44
45
|
|
45
46
|
private
|
46
47
|
|
48
|
+
def check_server(host, port)
|
49
|
+
unless wait_for_server(host: host, port: port, timeout: MAX_STARTUP_TIME)
|
50
|
+
logger.error "cannot reach server at http://#{host}:#{port}"
|
51
|
+
exit 1
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
47
55
|
def do_start(host, port, command)
|
48
56
|
if port_open?(host, port)
|
49
57
|
logger.error "A process is already running on #{host}:#{port}"
|
50
58
|
exit 2
|
51
59
|
end
|
52
|
-
|
60
|
+
|
53
61
|
STDERR.puts <<~MSG
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
62
|
+
==== Starting server ================================================================
|
63
|
+
#{command}
|
64
|
+
=====================================================================================
|
65
|
+
MSG
|
58
66
|
|
59
67
|
# start child process in a separate process group. at exit we'll
|
60
68
|
# kill the entire process group. This helps if the started process
|
@@ -91,11 +99,11 @@ module RSpec::Httpd
|
|
91
99
|
pid
|
92
100
|
end
|
93
101
|
|
94
|
-
def wait_for_server(host:, port:, pid
|
102
|
+
def wait_for_server(host:, port:, pid: nil, timeout:)
|
95
103
|
while timeout > 0
|
96
104
|
sleep 0.1
|
97
105
|
return true if port_open?(host, port)
|
98
|
-
return false if Process.waitpid(pid, Process::WNOHANG)
|
106
|
+
return false if pid && Process.waitpid(pid, Process::WNOHANG)
|
99
107
|
|
100
108
|
timeout -= 0.1
|
101
109
|
next if timeout > 0
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-httpd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Enrico Thierbach
|
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '0'
|
116
116
|
requirements: []
|
117
|
-
rubygems_version: 3.0.
|
117
|
+
rubygems_version: 3.0.6
|
118
118
|
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: RSpec testing for HTTP requests
|