diff --git a/lib/ruby_http_client.rb b/lib/ruby_http_client.rb index 495f498..3e5376d 100644 --- a/lib/ruby_http_client.rb +++ b/lib/ruby_http_client.rb @@ -83,7 +83,7 @@ def ratelimit # A simple REST client. class Client - attr_reader :host, :request_headers, :url_path, :request, :http + attr_reader :host, :request_headers, :url_path, :request, :http, :proxy_options # * *Args* : # - +host+ -> Base URL for the api. (e.g. https://api.sendgrid.com) # - +request_headers+ -> A hash of the headers you want applied on @@ -275,7 +275,8 @@ def _(name = nil) url_path = name ? @url_path + [name] : @url_path Client.new(host: @host, request_headers: @request_headers, version: @version, url_path: url_path, - http_options: @http_options) + http_options: @http_options, + proxy_options: @proxy_options) end # Dynamically add segments to the url, then call a method. diff --git a/test/test_ruby_http_client.rb b/test/test_ruby_http_client.rb index bbdd4f8..efdc14f 100644 --- a/test/test_ruby_http_client.rb +++ b/test/test_ruby_http_client.rb @@ -64,13 +64,15 @@ def setup @host = 'http://localhost:4010' @version = 'v3' @http_options = { open_timeout: 60, read_timeout: 60 } + @proxy_options = { host: '127.0.0.1', port: 8080, user: 'anonymous', pass: 'secret'} @client = MockRequest.new(host: @host, request_headers: @headers, version: @version) @client_with_options = MockRequest.new(host: @host, request_headers: @headers, version: @version, - http_options: @http_options) + http_options: @http_options, + proxy_options: @proxy_options) end def test_init @@ -266,6 +268,14 @@ def test__ assert_equal(['test'], url1.url_path) end + def test___with_client_with_options + url1 = @client_with_options._('test') + assert_equal(['test'], url1.url_path) + assert_equal(@host, url1.host) + assert_equal(@headers, url1.request_headers) + assert_equal(@proxy_options, url1.proxy_options) + end + def test_ratelimit_core expiry = Time.now.to_i + 1 rl = SendGrid::Response::Ratelimit.new(500, 100, expiry)