diff --git a/lib/couchrest.rb b/lib/couchrest.rb index ddd58fdd..92e666b3 100644 --- a/lib/couchrest.rb +++ b/lib/couchrest.rb @@ -78,6 +78,11 @@ def parse url } 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 f802e2d6..2ed8bb9c 100644 --- a/spec/couchrest/core/couchrest_spec.rb +++ b/spec/couchrest/core/couchrest_spec.rb @@ -188,4 +188,14 @@ 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