Add test for options as 5th param in array style calls
This commit is contained in:
parent
016689fa7c
commit
5941c0d877
|
@ -110,28 +110,46 @@ describe Google::APIClient do
|
||||||
|
|
||||||
describe 'when executing requests' do
|
describe 'when executing requests' do
|
||||||
before do
|
before do
|
||||||
|
@prediction = client.discovered_api('prediction', 'v1.2')
|
||||||
client.authorization = :oauth_2
|
client.authorization = :oauth_2
|
||||||
@connection = stub_connection do |stub|
|
@connection = stub_connection do |stub|
|
||||||
stub.get('/test') do |env|
|
stub.post('/prediction/v1.2/training?data=12345') do |env|
|
||||||
env[:request_headers]['Authorization'].should == 'Bearer 12345'
|
env[:request_headers]['Authorization'].should == 'Bearer 12345'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
@connection.verify
|
||||||
|
end
|
||||||
|
|
||||||
it 'should use default authorization' do
|
it 'should use default authorization' do
|
||||||
client.authorization.access_token = "12345"
|
client.authorization.access_token = "12345"
|
||||||
client.execute(:http_method => :get,
|
client.execute(
|
||||||
:uri => 'https://www.googleapis.com/test',
|
:api_method => @prediction.training.insert,
|
||||||
:connection => @connection)
|
:parameters => {'data' => '12345'},
|
||||||
|
:connection => @connection
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should use request scoped authorization when provided' do
|
it 'should use request scoped authorization when provided' do
|
||||||
client.authorization.access_token = "abcdef"
|
client.authorization.access_token = "abcdef"
|
||||||
new_auth = Signet::OAuth2::Client.new(:access_token => '12345')
|
new_auth = Signet::OAuth2::Client.new(:access_token => '12345')
|
||||||
client.execute(:http_method => :get,
|
client.execute(
|
||||||
:uri => 'https://www.googleapis.com/test',
|
:api_method => @prediction.training.insert,
|
||||||
:connection => @connection,
|
:parameters => {'data' => '12345'},
|
||||||
:authorization => new_auth)
|
:authorization => new_auth,
|
||||||
|
:connection => @connection
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should accept options in array style execute' do
|
||||||
|
client.authorization.access_token = "abcdef"
|
||||||
|
new_auth = Signet::OAuth2::Client.new(:access_token => '12345')
|
||||||
|
client.execute(
|
||||||
|
@prediction.training.insert, {'data' => '12345'}, '', {},
|
||||||
|
{ :authorization => new_auth, :connection => @connection }
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue