Make API match the README, remove StringResponse.

For YajlResponse the JSON body was being returned directly instead of
the response object, which conflicted with the README. I also removed
the StringResponse class since it wasn't really being used.
This commit is contained in:
Zack Hobson 2009-12-10 12:46:50 -08:00
parent dc25245ced
commit 47fc27ac6d
6 changed files with 8 additions and 33 deletions

View File

@ -1,6 +1,6 @@
= faraday
experiments in a rest api lib
Experiments in a REST API lib
Super alpha! Don't use it if you mind throwing away all the code when I change
the API on a whim.

View File

@ -1,9 +0,0 @@
module Faraday
class Response
class StringResponse < Response
def content
body
end
end
end
end

View File

@ -3,7 +3,6 @@ module Faraday
class Response
class YajlResponse < Response
attr_reader :body
alias content body
def initialize(headers = nil, body = nil)
super

View File

@ -15,14 +15,9 @@ class AdapterTest < Faraday::TestCase
assert_equal 'hello world', @connection.get('hello_world').body
end
it "retrieves the response JSON with StringResponse" do
@connection.response_class = Faraday::Response::StringResponse
assert_equal 'hello world', @connection.get('hello_world')
end
it "retrieves the response JSON with YajlResponse" do
it "retrieves the response body with YajlResponse" do
@connection.response_class = Faraday::Response::YajlResponse
assert_equal [1,2,3], @connection.get('json')
assert_equal [1,2,3], @connection.get('json').body
end
it "retrieves the response headers" do

View File

@ -11,23 +11,13 @@ class ResponseTest < Faraday::TestCase
end
end
describe "TestConnection#get with Faraday::StringResponse class" do
it "returns string body" do
conn = TestConnection.new do |stub|
stub.get('/hello') { [200, {}, 'hello world']}
end
conn.response_class = Faraday::Response::StringResponse
assert_equal 'hello world', conn.get('/hello')
end
end
describe "TestConnection#get with Faraday::YajlResponse class" do
it "returns string body" do
conn = TestConnection.new do |stub|
stub.get('/hello') { [200, {}, '[1,2,3]']}
end
conn.response_class = Faraday::Response::YajlResponse
assert_equal [1,2,3], conn.get('/hello')
assert_equal [1,2,3], conn.get('/hello').body
end
end
end