|
21 | 21 |
|
22 | 22 | shared_examples_for 'configurable user agent' do
|
23 | 23 | include ConnectionHelpers
|
24 |
| - |
| 24 | + |
25 | 25 | it 'should allow the user agent to be modified' do
|
26 | 26 | client.user_agent = 'Custom User Agent/1.2.3'
|
27 | 27 | client.user_agent.should == 'Custom User Agent/1.2.3'
|
|
60 | 60 |
|
61 | 61 | let(:client) { Google::APIClient.new(:application_name => 'API Client Tests') }
|
62 | 62 |
|
| 63 | + it "should pass the faraday options provided on initialization to FaraDay configuration block" do |
| 64 | + client = Google::APIClient.new(faraday_option: {timeout: 999}) |
| 65 | + client.connection.options.timeout.should == 999 |
| 66 | + end |
| 67 | + |
63 | 68 | it 'should make its version number available' do
|
64 | 69 | Google::APIClient::VERSION::STRING.should be_instance_of(String)
|
65 | 70 | end
|
|
74 | 79 | end
|
75 | 80 | it_should_behave_like 'configurable user agent'
|
76 | 81 | end
|
77 |
| - |
| 82 | + |
78 | 83 | describe 'configured for OAuth 1' do
|
79 | 84 | before do
|
80 | 85 | client.authorization = :oauth_1
|
|
106 | 111 | # TODO
|
107 | 112 | it_should_behave_like 'configurable user agent'
|
108 | 113 | end
|
109 |
| - |
| 114 | + |
110 | 115 | describe 'when executing requests' do
|
111 | 116 | before do
|
112 | 117 | @prediction = client.discovered_api('prediction', 'v1.2')
|
|
122 | 127 | after do
|
123 | 128 | @connection.verify
|
124 | 129 | end
|
125 |
| - |
| 130 | + |
126 | 131 | it 'should use default authorization' do
|
127 | 132 | client.authorization.access_token = "12345"
|
128 |
| - client.execute( |
| 133 | + client.execute( |
129 | 134 | :api_method => @prediction.training.insert,
|
130 | 135 | :parameters => {'data' => '12345'},
|
131 | 136 | :connection => @connection
|
|
135 | 140 | it 'should use request scoped authorization when provided' do
|
136 | 141 | client.authorization.access_token = "abcdef"
|
137 | 142 | new_auth = Signet::OAuth2::Client.new(:access_token => '12345')
|
138 |
| - client.execute( |
| 143 | + client.execute( |
139 | 144 | :api_method => @prediction.training.insert,
|
140 | 145 | :parameters => {'data' => '12345'},
|
141 | 146 | :authorization => new_auth,
|
142 | 147 | :connection => @connection
|
143 | 148 | )
|
144 | 149 | end
|
145 |
| - |
| 150 | + |
146 | 151 | it 'should accept options with batch/request style execute' do
|
147 | 152 | client.authorization.access_token = "abcdef"
|
148 | 153 | new_auth = Signet::OAuth2::Client.new(:access_token => '12345')
|
|
156 | 161 | :connection => @connection
|
157 | 162 | )
|
158 | 163 | end
|
159 |
| - |
160 |
| - |
| 164 | + |
| 165 | + |
161 | 166 | it 'should accept options in array style execute' do
|
162 | 167 | client.authorization.access_token = "abcdef"
|
163 | 168 | new_auth = Signet::OAuth2::Client.new(:access_token => '12345')
|
164 |
| - client.execute( |
| 169 | + client.execute( |
165 | 170 | @prediction.training.insert, {'data' => '12345'}, '', {},
|
166 |
| - { :authorization => new_auth, :connection => @connection } |
| 171 | + { :authorization => new_auth, :connection => @connection } |
167 | 172 | )
|
168 | 173 | end
|
169 |
| - end |
| 174 | + end |
170 | 175 |
|
171 | 176 | describe 'when retries enabled' do
|
172 | 177 | before do
|
|
176 | 181 | after do
|
177 | 182 | @connection.verify
|
178 | 183 | end
|
179 |
| - |
| 184 | + |
180 | 185 | it 'should follow redirects' do
|
181 | 186 | client.authorization = nil
|
182 | 187 | @connection = stub_connection do |stub|
|
|
188 | 193 | end
|
189 | 194 | end
|
190 | 195 |
|
191 |
| - client.execute( |
| 196 | + client.execute( |
192 | 197 | :uri => 'https://www.gogole.com/foo',
|
193 | 198 | :connection => @connection
|
194 | 199 | )
|
|
207 | 212 | end
|
208 | 213 | end
|
209 | 214 |
|
210 |
| - client.execute( |
| 215 | + client.execute( |
211 | 216 | :uri => 'https://www.gogole.com/foo',
|
212 | 217 | :connection => @connection
|
213 | 218 | )
|
|
224 | 229 | end
|
225 | 230 | end
|
226 | 231 |
|
227 |
| - client.execute( |
| 232 | + client.execute( |
228 | 233 | :uri => 'https://www.gogole.com/foo',
|
229 | 234 | :connection => @connection
|
230 | 235 | )
|
|
240 | 245 | end
|
241 | 246 | end
|
242 | 247 |
|
243 |
| - client.execute( |
| 248 | + client.execute( |
244 | 249 | :uri => 'https://www.gogole.com/foo',
|
245 | 250 | :connection => @connection,
|
246 | 251 | :authenticated => false
|
|
259 | 264 | end
|
260 | 265 | end
|
261 | 266 |
|
262 |
| - client.execute( |
| 267 | + client.execute( |
263 | 268 | :uri => 'https://www.gogole.com/foo',
|
264 | 269 | :connection => @connection
|
265 | 270 | ).status.should == 200
|
|
276 | 281 | end
|
277 | 282 | end
|
278 | 283 |
|
279 |
| - client.execute( |
| 284 | + client.execute( |
280 | 285 | :uri => 'https://www.gogole.com/foo',
|
281 | 286 | :connection => @connection
|
282 | 287 | ).status.should == 500
|
283 | 288 | count.should == 3
|
284 | 289 | end
|
285 | 290 |
|
286 |
| - end |
| 291 | + end |
287 | 292 | end
|
0 commit comments