Top Level Namespace
Defined Under Namespace
Modules: Curl, EventMachine, HTTP, Net, Test, WebMock, WebMockHTTPClients
Classes: MessageMock, PatchedStringIO, StubSocket, WebMockHTTPClient, WebMockJSONClient
Constant Summary
collapse
- RSPEC_NAMESPACE =
Spec
- RSPEC_CONFIGURER =
Spec::Runner
Instance Method Summary
collapse
Instance Method Details
#build_request_signature(req, reuse_existing = false) ⇒ Object
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
# File 'lib/webmock/http_lib_adapters/httpclient_adapter.rb', line 169
def build_request_signature(req, reuse_existing = false)
uri = WebMock::Util::URI.heuristic_parse(req..request_uri.to_s)
uri.query = WebMock::Util::QueryMapper.values_to_query(req..request_query, :notation => WebMock::Config.instance.query_values_notation) if req..request_query
uri.port = req..request_uri.port
@request_filter.each do |filter|
filter.filter_request(req)
end
= req..all.inject({}) do |hdrs, |
hdrs[[0]] ||= []
hdrs[[0]] << [1]
hdrs
end
= (uri).merge()
signature = WebMock::RequestSignature.new(
req..request_method.downcase.to_sym,
uri.to_s,
:body => req.http_body.dump,
:headers =>
)
if reuse_existing && previous_signature = previous_signature_for(signature)
return previous_signature
end
signature
end
|
#build_webmock_response(httpclient_response, body = nil) ⇒ Object
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
# File 'lib/webmock/http_lib_adapters/httpclient_adapter.rb', line 142
def build_webmock_response(httpclient_response, body = nil)
webmock_response = WebMock::Response.new
webmock_response.status = [httpclient_response.status, httpclient_response.reason]
webmock_response. = {}.tap do |hash|
httpclient_response..all.each do |(key, value)|
if hash.has_key?(key)
hash[key] = Array(hash[key]) + [value]
else
hash[key] = value
end
end
end
if body
webmock_response.body = body
elsif httpclient_response.content.respond_to?(:read)
webmock_response.body = httpclient_response.content.read
body = HTTP::Message::Body.new
body.init_response(StringIO.new(webmock_response.body))
httpclient_response.body = body
else
webmock_response.body = httpclient_response.content
end
webmock_response
end
|
#previous_signature_for(signature) ⇒ Object
#webmock_request_signatures ⇒ Object
206
207
208
|
# File 'lib/webmock/http_lib_adapters/httpclient_adapter.rb', line 206
def webmock_request_signatures
@webmock_request_signatures ||= []
end
|
#webmock_responses ⇒ Object
200
201
202
203
204
|
# File 'lib/webmock/http_lib_adapters/httpclient_adapter.rb', line 200
def webmock_responses
@webmock_responses ||= Hash.new do |hash, request_signature|
hash[request_signature] = WebMock::StubRegistry.instance.response_for_request(request_signature)
end
end
|