rspec-httpd 0.0.5 → 0.0.7

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/rspec/httpd/client.rb +17 -12
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e88c3329bebe29bcae34340feeb0585974fdc35b5a8b35f0451d7208e51f9c4f
4
- data.tar.gz: a56d6764673da02062227b36b141ba8bdc163cb864489688f988a0f47a63f036
3
+ metadata.gz: 37a19747dc166776870ef12397bff1359adfa6ae7837b8a648debd51444afe98
4
+ data.tar.gz: c72e98898b8df5b5d199648da626106c71c74051e55345aa8e7a51ffb0679aa6
5
5
  SHA512:
6
- metadata.gz: 9e1ac270f0c7e49cb2a923964bdc3ebbb7b0f91e64442768dff60a04063051ac4cce35d68cd3ab8860b0c4103c55c79c5526e3d0a834e987e32a405c3a212d13
7
- data.tar.gz: 13a98bb4462fcdebb3cc33f40975e15a658a73f1c9e70e299dfa8c9a21b8ef407d316b3b24fca8cf5909c79d486d8e1040dc3a21ec454383cd690a9ac3e6c9a8
6
+ metadata.gz: 205df4ff0cf9d2dd6d333160bb99638c45d5576e2bf89e15556e7e36b71335695d241c257d3a058d677b96c4cf4c7bc172a80b475c5909ff6563ca07e7e84b65
7
+ data.tar.gz: a59543d26b2e72e975ca8b985efd0f4de59fa0f053f703792a83b73e26d774bf32b87692fd7dd25a984b808677a84105d25888a6b56eb17c248811124c49096a
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.7
@@ -52,26 +52,31 @@ module RSpec::Httpd
52
52
  private
53
53
 
54
54
  def run_request(request_klass, url, body:, headers:)
55
- @result = nil
55
+ # reset all results from previous run
56
+ @request = @response = @headers = @result = nil
56
57
 
57
- build_request!(request_klass, url, body: body, headers: headers)
58
- log_request!
59
- @response = Net::HTTP.start(host, port) { |http| http.request(request) }
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!(request_klass, url, body:, headers:)
63
- @request = request_klass.new url, headers
64
- if body
65
- @request["Content-Type"] = "application/json"
66
- @request.body = JSON.generate body
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.uri} #{body.inspect[0..100]}"
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.uri}"
79
+ RSpec::Httpd.logger.info "#{request.method} #{request.path}"
75
80
  end
76
81
  end
77
82
 
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.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Enrico Thierbach