lib/api_resource/mocks.rb in api_resource-0.2.6 vs lib/api_resource/mocks.rb in api_resource-0.2.7
- old
+ new
@@ -239,20 +239,28 @@
# request = ApiResource::Request.new(:post, path, body, headers)
# self.class.requests << request
# if response = LifebookerClient::Mocks.find_response(request)
# response
# else
- # raise InvalidRequestError.new("Could not find a response recorded for #{request.to_s} - Responses recorded are: - #{inspect_responses}")
+ # raise InvalidRequestError.new("Could not find a response
+ # recorded for #{request.to_s} - Responses recorded are: -
+ # #{inspect_responses}")
# end
# end
instance_eval <<-EOE, __FILE__, __LINE__ + 1
def #{method}(path, #{'body, ' if has_body}headers)
opts = {:headers => headers}
#{"opts[:body] = body" if has_body}
request = MockRequest.new(:#{method}, path, opts)
self.requests << request
if response = Mocks.find_response(request)
- response[:response].tap{|resp| resp.generate_response(response[:params])}
+ response[:response].tap{|resp|
+ resp.generate_response(
+ request.params
+ .with_indifferent_access
+ .merge(response[:params].with_indifferent_access)
+ )
+ }
else
raise ApiResource::ResourceNotFound.new(
MockResponse.new({}, {:headers => {"Content-type" => "application/json"}, :status_code => 404}),
:message => "\nCould not find a response recorded for \#{request.pretty_inspect}\n" +
"Potential Responses Are:\n" +
\ No newline at end of file