From 108ec0a28edde21e4b11cf834c39e10f5880e021 Mon Sep 17 00:00:00 2001 From: Joe Martinez Date: Sat, 10 Jan 2009 22:52:08 -0500 Subject: [PATCH] Add proxy support --- lib/couchrest.rb | 5 +++++ spec/couchrest/core/couchrest_spec.rb | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/couchrest.rb b/lib/couchrest.rb index ddd58fd..92e666b 100644 --- a/lib/couchrest.rb +++ b/lib/couchrest.rb @@ -78,6 +78,11 @@ module CouchRest } end + # set proxy for RestClient to use + def proxy url + RestClient.proxy = url + end + # ensure that a database exists # creates it if it isn't already there # returns it after it's been created diff --git a/spec/couchrest/core/couchrest_spec.rb b/spec/couchrest/core/couchrest_spec.rb index f802e2d..2ed8bb9 100644 --- a/spec/couchrest/core/couchrest_spec.rb +++ b/spec/couchrest/core/couchrest_spec.rb @@ -188,4 +188,14 @@ describe CouchRest do end end + describe "using a proxy for RestClient connections" do + it "should set proxy url for RestClient" do + CouchRest.proxy 'http://localhost:8888/' + proxy_uri = URI.parse(RestClient.proxy) + proxy_uri.host.should eql( 'localhost' ) + proxy_uri.port.should eql( 8888 ) + CouchRest.proxy nil + end + end + end \ No newline at end of file