rspec-httpd 0.0.12 → 0.0.14

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
2
  SHA256:
3
- metadata.gz: ae68a23828d76493ce80d96bf2b2afee033a14e46da3a3ff6e3c67320bb5d625
4
- data.tar.gz: 0bd56b3fa44e20b62f26560fb4fca7b187cab35622c49184292d2378a632b536
3
+ metadata.gz: c71c6a8e039811020f1c135751a4068adafb8f9e6992833fe2449661060146ce
4
+ data.tar.gz: 2875628708bf20325ce4323dde9d253f9955493f2e8af2c65828a2054481d421
5
5
  SHA512:
6
- metadata.gz: 70dde7dd27a7cac04ebeefda0b4f5a1609caa803cff76edaf675a7d5d92a9f701b1feca713d81f1804bf8f4831ef9a5dc7711249d933d923edbf567bbc9cf125
7
- data.tar.gz: 3a32fe486726baf2a80a2cefbc3009e874f800e4cee8c927a3bfe85aba897986ab9452c68da952c7321e0775fed6fa863812c202c6d9a9b26a7907e49461b515
6
+ metadata.gz: b262a9cbcb738a6956c32bafee8b2ab234cee9d8cf1fe218c2006b6d8e19b8b22311f2201253d49b875a9ade93b6da1a529e456db522039c4441e93e583bf9d9
7
+ data.tar.gz: b834501793639f9c49ff836d7eb1d25f0b170743bfe3c98186f7219fcd0f30705e97e2ffd331aad25fac55dccee6abdd66384a1598479e5d504fa90f85e187b5
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.12
1
+ 0.0.14
@@ -71,22 +71,20 @@ module RSpec::Httpd
71
71
  #
72
72
  # expect_response 201
73
73
  #
74
- if expected.is_a?(Integer) && status.nil?
75
- expect(client.status).to eq(expected)
76
- return
77
- end
74
+ expected_status = expected.is_a?(Integer) && status.nil? ? expected : status || 200
75
+
76
+ request, response = client.request, client.response
78
77
 
79
- # do_expect_last_request is implemented in RSpec::Httpd::Expectation, and mixed in
80
- # here, because it needs access to the expect() implementation.
78
+ expect(client.status).to eq(expected_status),
79
+ "status should be #{expected_status}, but is #{client.status}, on '#{request.method} #{request.path}'"
81
80
 
82
- expect(client.status).to eq(status || 200)
83
- return if expected.nil?
81
+ return if expected.nil? || expected.is_a?(Integer)
84
82
 
85
83
  begin
86
84
  # expect! comes from the expectation gem
87
85
  expect! client.result => expected
88
86
  rescue ::Expectation::Matcher::Mismatch => e
89
- raise ExpectationFailed.new(e, request: client.request, response: client.response), cause: nil
87
+ raise ExpectationFailed.new(e, request: request, response: response), cause: nil
90
88
  end
91
89
  end
92
90
 
@@ -34,6 +34,11 @@ module RSpec::Httpd
34
34
  run_request(::Net::HTTP::Get, url, body: nil, headers: headers)
35
35
  end
36
36
 
37
+ # A HEAD request
38
+ def head(url, headers: {})
39
+ run_request(::Net::HTTP::Head, url, body: nil, headers: headers)
40
+ end
41
+
37
42
  # A POST request
38
43
  def post(url, body, headers: {})
39
44
  run_request(::Net::HTTP::Post, url, body: body, headers: headers)
@@ -104,6 +109,8 @@ module RSpec::Httpd
104
109
 
105
110
  module ResponseParser
106
111
  def self.parse(response)
112
+ return nil if response.body.nil?
113
+
107
114
  content_type = response["content-type"]
108
115
 
109
116
  result = if content_type&.include?("application/json")
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.12
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Enrico Thierbach