allows to pass FaraDay options furthur to FaraDay configuration block upon client initialization

This commit is contained in:
Janis Kesteris 2014-07-29 15:06:45 +02:00
parent bfa5225766
commit 2f88bc5487
2 changed files with 30 additions and 20 deletions

View File

@ -119,6 +119,11 @@ module Google
faraday.ssl.ca_file = ca_file faraday.ssl.ca_file = ca_file
faraday.ssl.verify = true faraday.ssl.verify = true
faraday.adapter Faraday.default_adapter faraday.adapter Faraday.default_adapter
if options[:faraday_option].is_a?(Hash)
options[:faraday_option].each_pair do |option, value|
faraday.options.send("#{option}=", value)
end
end
end end
return self return self
end end

View File

@ -60,6 +60,11 @@ describe Google::APIClient do
let(:client) { Google::APIClient.new(:application_name => 'API Client Tests') } let(:client) { Google::APIClient.new(:application_name => 'API Client Tests') }
it "should pass the faraday options provided on initialization to FaraDay configuration block" do
client = Google::APIClient.new(faraday_option: {timeout: 999})
client.connection.options.timeout.should == 999
end
it 'should make its version number available' do it 'should make its version number available' do
Google::APIClient::VERSION::STRING.should be_instance_of(String) Google::APIClient::VERSION::STRING.should be_instance_of(String)
end end