|
20 | 20 |
|
21 | 21 | shared_examples_for 'configurable user agent' do
|
22 | 22 | include ConnectionHelpers
|
23 |
| - |
| 23 | + |
24 | 24 | it 'should allow the user agent to be modified' do
|
25 | 25 | client.user_agent = 'Custom User Agent/1.2.3'
|
26 | 26 | expect(client.user_agent).to eq('Custom User Agent/1.2.3')
|
|
59 | 59 |
|
60 | 60 | let(:client) { Google::APIClient.new(:application_name => 'API Client Tests') }
|
61 | 61 |
|
| 62 | + it "should pass the faraday options provided on initialization to FaraDay configuration block" do |
| 63 | + client = Google::APIClient.new(faraday_option: {timeout: 999}) |
| 64 | + expect(client.connection.options.timeout).to be == 999 |
| 65 | + end |
| 66 | + |
62 | 67 | it 'should make its version number available' do
|
63 | 68 | expect(Google::APIClient::VERSION::STRING).to be_instance_of(String)
|
64 | 69 | end
|
|
73 | 78 | end
|
74 | 79 | it_should_behave_like 'configurable user agent'
|
75 | 80 | end
|
76 |
| - |
| 81 | + |
77 | 82 | describe 'configured for OAuth 1' do
|
78 | 83 | before do
|
79 | 84 | client.authorization = :oauth_1
|
|
107 | 112 | # TODO
|
108 | 113 | it_should_behave_like 'configurable user agent'
|
109 | 114 | end
|
110 |
| - |
| 115 | + |
111 | 116 | describe 'when executing requests' do
|
112 | 117 | before do
|
113 | 118 | @prediction = client.discovered_api('prediction', 'v1.2')
|
|
123 | 128 | after do
|
124 | 129 | @connection.verify
|
125 | 130 | end
|
126 |
| - |
| 131 | + |
127 | 132 | it 'should use default authorization' do
|
128 | 133 | client.authorization.access_token = "12345"
|
129 |
| - client.execute( |
| 134 | + client.execute( |
130 | 135 | :api_method => @prediction.training.insert,
|
131 | 136 | :parameters => {'data' => '12345'},
|
132 | 137 | :connection => @connection
|
|
136 | 141 | it 'should use request scoped authorization when provided' do
|
137 | 142 | client.authorization.access_token = "abcdef"
|
138 | 143 | new_auth = Signet::OAuth2::Client.new(:access_token => '12345')
|
139 |
| - client.execute( |
| 144 | + client.execute( |
140 | 145 | :api_method => @prediction.training.insert,
|
141 | 146 | :parameters => {'data' => '12345'},
|
142 | 147 | :authorization => new_auth,
|
143 | 148 | :connection => @connection
|
144 | 149 | )
|
145 | 150 | end
|
146 |
| - |
| 151 | + |
147 | 152 | it 'should accept options with batch/request style execute' do
|
148 | 153 | client.authorization.access_token = "abcdef"
|
149 | 154 | new_auth = Signet::OAuth2::Client.new(:access_token => '12345')
|
|
157 | 162 | :connection => @connection
|
158 | 163 | )
|
159 | 164 | end
|
160 |
| - |
161 |
| - |
| 165 | + |
| 166 | + |
162 | 167 | it 'should accept options in array style execute' do
|
163 | 168 | client.authorization.access_token = "abcdef"
|
164 | 169 | new_auth = Signet::OAuth2::Client.new(:access_token => '12345')
|
165 |
| - client.execute( |
| 170 | + client.execute( |
166 | 171 | @prediction.training.insert, {'data' => '12345'}, '', {},
|
167 |
| - { :authorization => new_auth, :connection => @connection } |
| 172 | + { :authorization => new_auth, :connection => @connection } |
168 | 173 | )
|
169 | 174 | end
|
170 |
| - end |
| 175 | + end |
171 | 176 |
|
172 | 177 | describe 'when retries enabled' do
|
173 | 178 | before do
|
|
177 | 182 | after do
|
178 | 183 | @connection.verify
|
179 | 184 | end
|
180 |
| - |
| 185 | + |
181 | 186 | it 'should follow redirects' do
|
182 | 187 | client.authorization = nil
|
183 | 188 | @connection = stub_connection do |stub|
|
|
284 | 289 | expect(count).to eq(3)
|
285 | 290 | end
|
286 | 291 |
|
287 |
| - end |
| 292 | + end |
288 | 293 | end
|
0 commit comments