Skip to content

Commit

Permalink
fixing custom respoinse handler usage
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermesilveira committed Oct 20, 2010
1 parent 0700113 commit a82b3ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions lib/restfulie/client/http/request_adapter.rb
Expand Up @@ -170,6 +170,7 @@ def request!(method, path, *args)
response = Restfulie::Client.cache_provider.get([@host, path], http_request, method)
return response if response
response = http_request.send(method, path, *args)
debugger if path=="/test/701"
response = ResponseHandler.handle(method, path, response)
rescue Exception => e
Restfulie::Common::Logger.logger.error(e)
Expand Down
10 changes: 5 additions & 5 deletions tests/spec/requests/http/adapter_spec.rb
Expand Up @@ -202,20 +202,20 @@

class FakeResponse < ::Restfulie::Client::HTTP::Response
end
::Restfulie::Client::HTTP::ResponseHandler.register(701,FakeResponse)
::Restfulie::Client::HTTP::ResponseHandler.register(307,FakeResponse)

let(:client) { Restfulie.at("http://localhost:4567") }

it 'should have FakeResponder as Response Handler to 201' do
::Restfulie::Client::HTTP::ResponseHandler.handlers(701).should equal FakeResponse
it 'should have FakeResponder as Response Handler to 307' do
::Restfulie::Client::HTTP::ResponseHandler.handlers(307).should equal FakeResponse
end

it 'should respond FakeResponse' do
client.get('/test/701').should equal FakeResponse
client.at('/test/307').get.response.class.should equal FakeResponse
end

it 'should respond default Response' do
client.get('/test/299')[2].class.should equal ::Restfulie::Client::HTTP::Response
client.at('/test/299').get[2].class.should equal ::Restfulie::Client::HTTP::Response
end

end
Expand Down

0 comments on commit a82b3ea

Please sign in to comment.