rspec-httpd 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/rspec/httpd/client.rb +17 -12
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37a19747dc166776870ef12397bff1359adfa6ae7837b8a648debd51444afe98
|
4
|
+
data.tar.gz: c72e98898b8df5b5d199648da626106c71c74051e55345aa8e7a51ffb0679aa6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 205df4ff0cf9d2dd6d333160bb99638c45d5576e2bf89e15556e7e36b71335695d241c257d3a058d677b96c4cf4c7bc172a80b475c5909ff6563ca07e7e84b65
|
7
|
+
data.tar.gz: a59543d26b2e72e975ca8b985efd0f4de59fa0f053f703792a83b73e26d774bf32b87692fd7dd25a984b808677a84105d25888a6b56eb17c248811124c49096a
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.7
|
data/lib/rspec/httpd/client.rb
CHANGED
@@ -52,26 +52,31 @@ module RSpec::Httpd
|
|
52
52
|
private
|
53
53
|
|
54
54
|
def run_request(request_klass, url, body:, headers:)
|
55
|
-
|
55
|
+
# reset all results from previous run
|
56
|
+
@request = @response = @headers = @result = nil
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
58
|
+
@response = Net::HTTP.start(host, port) do |http|
|
59
|
+
@request = build_request(request_klass, url, body: body, headers: headers)
|
60
|
+
|
61
|
+
log_request(request)
|
62
|
+
http.request(request)
|
63
|
+
end
|
60
64
|
end
|
61
65
|
|
62
|
-
def build_request
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
66
|
+
def build_request(request_klass, url, body:, headers:)
|
67
|
+
request_klass.new(url, headers).tap do |request|
|
68
|
+
if body
|
69
|
+
request["Content-Type"] = "application/json"
|
70
|
+
request.body = JSON.generate(body)
|
71
|
+
end
|
67
72
|
end
|
68
73
|
end
|
69
74
|
|
70
|
-
def log_request
|
75
|
+
def log_request(request)
|
71
76
|
if request.body
|
72
|
-
RSpec::Httpd.logger.info "#{request.method} #{request.
|
77
|
+
RSpec::Httpd.logger.info "#{request.method} #{request.path} #{request.body.inspect[0..100]}"
|
73
78
|
else
|
74
|
-
RSpec::Httpd.logger.info "#{request.method} #{request.
|
79
|
+
RSpec::Httpd.logger.info "#{request.method} #{request.path}"
|
75
80
|
end
|
76
81
|
end
|
77
82
|
|