Permalink
Browse files

Add Chainable#with_response, facading Options#with_response.

  • Loading branch information...
1 parent 7a89eee commit b4fb80486a55361c8db631aaca49f2a984b08bc9 @blambeau blambeau committed Jul 16, 2012
Showing with 16 additions and 0 deletions.
  1. +4 −0 CHANGES.md
  2. +5 −0 lib/http/chainable.rb
  3. +7 −0 spec/http_spec.rb
View
@@ -1,3 +1,7 @@
+master
+------
+* Http#with_response (through Chainable)
+
0.2.0
-----
* Request and response objects
@@ -71,6 +71,11 @@ def via(*proxy)
end
alias_method :through, :via
+ # Specify the kind of response to return (:auto, :object, :body, :parsed_body)
+ def with_response(response_type)
+ branch default_options.with_response(response_type)
+ end
+
# Make a request with the given headers
def with_headers(headers)
branch default_options.with_headers(headers)
View
@@ -11,6 +11,13 @@
response.should match(/<!doctype html>/)
end
+ context "with_response" do
+ it 'allows specifying :object' do
+ res = Http.with_response(:object).get test_endpoint
+ res.should be_a(Http::Response)
+ end
+ end
+
context "with headers" do
it "should be easy" do
response = Http.accept(:json).get test_endpoint

0 comments on commit b4fb804

Please sign in to comment.