Skip to content

Commit

Permalink
Return a HTTParty response instead of the parsed value
Browse files Browse the repository at this point in the history
  • Loading branch information
Darcy Laycock committed Mar 3, 2011
1 parent 17f2e04 commit 69e024e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/api_smith/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def delete(path, options = {})
# @option options [#call] :transform An object, invoked via #call, that takes the response and
# transformers it into a useable form.
#
# @return the response, defaults to the raw HTTParty::Response
#
# @see #path_for
# @see #extract_response
# @see #transform_response
Expand All @@ -109,11 +111,10 @@ def request!(method, path, options, *param_types)
end
# Finally, use HTTParty to get the response
response = self.class.send method, full_path, request_options
parsed_response = response.parsed_response
# Pre-process the response to check for errors.
check_response_errors parsed_response
check_response_errors response
# Unpack the response using the :response_container option
inner_response = extract_response path, parsed_response, options
inner_response = extract_response path, response, options
# Finally, apply any transformations
transform_response inner_response, options
end
Expand Down
5 changes: 5 additions & 0 deletions spec/api_smith/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
client.delete('/echo').should == {"verb" => "delete", "echo" => nil}
end

it 'should default to returning a httparty response' do
response = client.get('/echo')
response.class.should == HTTParty::Response
end

describe 'passing options' do

it 'should allow you to pass extra query string options' do
Expand Down

0 comments on commit 69e024e

Please sign in to comment.