signet 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,27 +41,27 @@ describe Signet::OAuth1::Client, 'unconfigured' do
41
41
  end
42
42
 
43
43
  it 'should have no temporary_credential_uri' do
44
- @client.temporary_credential_uri.should == nil
44
+ expect(@client.temporary_credential_uri).to be_nil
45
45
  end
46
46
 
47
47
  it 'should allow the temporary_credential_uri to be set to a String' do
48
48
  @client.temporary_credential_uri = "http://example.com/"
49
- @client.temporary_credential_uri.should === "http://example.com/"
49
+ expect(@client.temporary_credential_uri.to_s).to eq "http://example.com/"
50
50
  end
51
51
 
52
52
  it 'should allow the temporary_credential_uri to be set to a URI' do
53
53
  @client.temporary_credential_uri =
54
54
  Addressable::URI.parse("http://example.com/")
55
- @client.temporary_credential_uri.should === "http://example.com/"
55
+ expect(@client.temporary_credential_uri.to_s).to eq "http://example.com/"
56
56
  end
57
57
 
58
58
  it 'should have no authorization_uri' do
59
- @client.authorization_uri.should == nil
59
+ expect(@client.authorization_uri).to be_nil
60
60
  end
61
61
 
62
62
  it 'should allow the authorization_uri to be set to a String' do
63
63
  @client.authorization_uri = 'http://example.com/authorize'
64
- @client.authorization_uri.to_s.should include(
64
+ expect(@client.authorization_uri.to_s).to include(
65
65
  'http://example.com/authorize'
66
66
  )
67
67
  end
@@ -70,7 +70,7 @@ describe Signet::OAuth1::Client, 'unconfigured' do
70
70
  @client.authorization_uri = {
71
71
  :scheme => 'http', :host => 'example.com', :path => '/authorize'
72
72
  }
73
- @client.authorization_uri.to_s.should include(
73
+ expect(@client.authorization_uri.to_s).to include(
74
74
  'http://example.com/authorize'
75
75
  )
76
76
  end
@@ -78,321 +78,318 @@ describe Signet::OAuth1::Client, 'unconfigured' do
78
78
  it 'should allow the authorization_uri to be set to a URI' do
79
79
  @client.authorization_uri =
80
80
  Addressable::URI.parse('http://example.com/authorize')
81
- @client.authorization_uri.to_s.should include(
81
+ expect(@client.authorization_uri.to_s).to include(
82
82
  'http://example.com/authorize'
83
83
  )
84
84
  end
85
85
 
86
86
  it 'should have no token_credential_uri' do
87
- @client.token_credential_uri.should == nil
87
+ expect(@client.token_credential_uri).to be_nil
88
88
  end
89
89
 
90
90
  it 'should allow the token_credential_uri to be set to a String' do
91
91
  @client.token_credential_uri = "http://example.com/"
92
- @client.token_credential_uri.should === "http://example.com/"
92
+ expect(@client.token_credential_uri.to_s).to eq "http://example.com/"
93
93
  end
94
94
 
95
95
  it 'should allow the token_credential_uri to be set to a Hash' do
96
96
  @client.token_credential_uri = {
97
97
  :scheme => 'http', :host => 'example.com', :path => '/token'
98
98
  }
99
- @client.token_credential_uri.to_s.should === 'http://example.com/token'
99
+ expect(@client.token_credential_uri.to_s).to eq 'http://example.com/token'
100
100
  end
101
101
 
102
102
  it 'should allow the token_credential_uri to be set to a URI' do
103
103
  @client.token_credential_uri =
104
104
  Addressable::URI.parse("http://example.com/")
105
- @client.token_credential_uri.should === "http://example.com/"
105
+ expect(@client.token_credential_uri.to_s).to eq "http://example.com/"
106
106
  end
107
107
 
108
108
  it 'should have no client_credential' do
109
- @client.client_credential.should == nil
109
+ expect(@client.client_credential).to be_nil
110
110
  end
111
111
 
112
112
  it 'should raise an error for partially set client credentials' do
113
113
  @client.client_credential_key = "12345"
114
114
  @client.client_credential_secret = nil
115
- (lambda do
115
+ expect(lambda do
116
116
  @client.client_credential
117
- end).should raise_error(ArgumentError)
117
+ end).to raise_error(ArgumentError)
118
118
  end
119
119
 
120
120
  it 'should raise an error for partially set client credentials' do
121
121
  @client.client_credential_key = nil
122
122
  @client.client_credential_secret = "54321"
123
- (lambda do
123
+ expect(lambda do
124
124
  @client.client_credential
125
- end).should raise_error(ArgumentError)
125
+ end).to raise_error(ArgumentError)
126
126
  end
127
127
 
128
128
  it 'should allow the client_credential to be set to a ' +
129
129
  'Signet::OAuth1::Credential' do
130
130
  @client.client_credential =
131
131
  Signet::OAuth1::Credential.new("12345", "54321")
132
- @client.client_credential_key.should == "12345"
133
- @client.client_credential_secret.should == "54321"
134
- @client.client_credential.should ==
135
- Signet::OAuth1::Credential.new("12345", "54321")
132
+ expect(@client.client_credential_key).to eq "12345"
133
+ expect(@client.client_credential_secret).to eq "54321"
134
+ expect(@client.client_credential).to eq Signet::OAuth1::Credential.new("12345", "54321")
136
135
  end
137
136
 
138
137
  it 'should allow the client_credential to be set to nil' do
139
138
  @client.client_credential_key = "12345"
140
139
  @client.client_credential_secret = "54321"
141
- @client.client_credential_key.should == "12345"
142
- @client.client_credential_secret.should == "54321"
140
+ expect(@client.client_credential_key).to eq "12345"
141
+ expect(@client.client_credential_secret).to eq "54321"
143
142
  @client.client_credential = nil
144
- @client.client_credential.should == nil
145
- @client.client_credential_key.should == nil
146
- @client.client_credential_secret.should == nil
143
+ expect(@client.client_credential).to be_nil
144
+ expect(@client.client_credential_key).to be_nil
145
+ expect(@client.client_credential_secret).to be_nil
147
146
  end
148
147
 
149
148
  it 'should not allow the client_credential to be set to a bogus value' do
150
- (lambda do
149
+ expect(lambda do
151
150
  @client.client_credential = 42
152
- end).should raise_error(TypeError)
151
+ end).to raise_error(TypeError)
153
152
  end
154
153
 
155
154
  it 'should have no client_credential_key' do
156
- @client.client_credential_key.should == nil
155
+ expect(@client.client_credential_key).to be_nil
157
156
  end
158
157
 
159
158
  it 'should allow the client_credential_key to be set to a String' do
160
159
  @client.client_credential_key = "12345"
161
- @client.client_credential_key.should == "12345"
160
+ expect(@client.client_credential_key).to eq "12345"
162
161
  end
163
162
 
164
163
  it 'should not allow the client_credential_key to be set to a non-String' do
165
- (lambda do
164
+ expect(lambda do
166
165
  @client.client_credential_key = 12345
167
- end).should raise_error(TypeError)
166
+ end).to raise_error(TypeError)
168
167
  end
169
168
 
170
169
  it 'should have no client_credential_secret' do
171
- @client.client_credential_secret.should == nil
170
+ expect(@client.client_credential_secret).to be_nil
172
171
  end
173
172
 
174
173
  it 'should allow the client_credential_secret to be set to a String' do
175
174
  @client.client_credential_secret = "54321"
176
- @client.client_credential_secret.should === "54321"
175
+ expect(@client.client_credential_secret).to eq "54321"
177
176
  end
178
177
 
179
178
  it 'should not allow the client_credential_secret ' +
180
179
  'to be set to a non-String' do
181
- (lambda do
180
+ expect(lambda do
182
181
  @client.client_credential_secret = 54321
183
- end).should raise_error(TypeError)
182
+ end).to raise_error(TypeError)
184
183
  end
185
184
 
186
185
  it 'should have an out-of-band callback' do
187
- @client.callback.should == ::Signet::OAuth1::OUT_OF_BAND
186
+ expect(@client.callback).to eq ::Signet::OAuth1::OUT_OF_BAND
188
187
  end
189
188
 
190
189
  it 'should allow the callback to be set to a String' do
191
190
  @client.callback = "http://example.com/callback"
192
- @client.callback.should == "http://example.com/callback"
191
+ expect(@client.callback).to eq "http://example.com/callback"
193
192
  end
194
193
 
195
194
  it 'should allow the callback to be set to a URI' do
196
195
  @client.callback =
197
196
  Addressable::URI.parse("http://example.com/callback")
198
- @client.callback.should == "http://example.com/callback"
197
+ expect(@client.callback).to eq "http://example.com/callback"
199
198
  end
200
199
 
201
200
  it 'should not allow the callback to be set to a non-String' do
202
- (lambda do
201
+ expect(lambda do
203
202
  @client.callback = 12345
204
- end).should raise_error(TypeError)
203
+ end).to raise_error(TypeError)
205
204
  end
206
205
 
207
206
  it 'should raise an error if the temporary credentials URI is not set' do
208
207
  @client.client_credential_key = 'dpf43f3p2l4k3l03'
209
208
  @client.client_credential_secret = 'kd94hf93k423kf44'
210
- (lambda do
209
+ expect(lambda do
211
210
  @client.generate_temporary_credential_request
212
- end).should raise_error(ArgumentError)
211
+ end).to raise_error(ArgumentError)
213
212
  end
214
213
 
215
214
  it 'should raise an error if the client credential key is not set' do
216
215
  @client.temporary_credential_uri =
217
216
  'http://example.com/temporary_credentials'
218
217
  @client.client_credential_secret = 'kd94hf93k423kf44'
219
- (lambda do
218
+ expect(lambda do
220
219
  @client.generate_temporary_credential_request
221
- end).should raise_error(ArgumentError)
220
+ end).to raise_error(ArgumentError)
222
221
  end
223
222
 
224
223
  it 'should raise an error if the client credential secret is not set' do
225
224
  @client.temporary_credential_uri =
226
225
  'http://example.com/temporary_credentials'
227
226
  @client.client_credential_key = 'dpf43f3p2l4k3l03'
228
- (lambda do
227
+ expect(lambda do
229
228
  @client.generate_temporary_credential_request
230
- end).should raise_error(ArgumentError)
229
+ end).to raise_error(ArgumentError)
231
230
  end
232
231
 
233
232
  it 'should have no temporary_credential' do
234
- @client.temporary_credential.should == nil
233
+ expect(@client.temporary_credential).to be_nil
235
234
  end
236
235
 
237
236
  it 'should raise an error for partially set temporary credentials' do
238
237
  @client.temporary_credential_key = "12345"
239
238
  @client.temporary_credential_secret = nil
240
- (lambda do
239
+ expect(lambda do
241
240
  @client.temporary_credential
242
- end).should raise_error(ArgumentError)
241
+ end).to raise_error(ArgumentError)
243
242
  end
244
243
 
245
244
  it 'should raise an error for partially set temporary credentials' do
246
245
  @client.temporary_credential_key = nil
247
246
  @client.temporary_credential_secret = "54321"
248
- (lambda do
247
+ expect(lambda do
249
248
  @client.temporary_credential
250
- end).should raise_error(ArgumentError)
249
+ end).to raise_error(ArgumentError)
251
250
  end
252
251
 
253
252
  it 'should allow the temporary_credential to be set to a ' +
254
253
  'Signet::OAuth1::Credential' do
255
254
  @client.temporary_credential =
256
255
  Signet::OAuth1::Credential.new("12345", "54321")
257
- @client.temporary_credential_key.should == "12345"
258
- @client.temporary_credential_secret.should == "54321"
259
- @client.temporary_credential.should ==
260
- Signet::OAuth1::Credential.new("12345", "54321")
256
+ expect(@client.temporary_credential_key).to eq "12345"
257
+ expect(@client.temporary_credential_secret).to eq "54321"
258
+ expect(@client.temporary_credential).to eq Signet::OAuth1::Credential.new("12345", "54321")
261
259
  end
262
260
 
263
261
  it 'should allow the temporary_credential to be set to nil' do
264
262
  @client.temporary_credential_key = "12345"
265
263
  @client.temporary_credential_secret = "54321"
266
- @client.temporary_credential_key.should == "12345"
267
- @client.temporary_credential_secret.should == "54321"
264
+ expect(@client.temporary_credential_key).to eq "12345"
265
+ expect(@client.temporary_credential_secret).to eq "54321"
268
266
  @client.temporary_credential = nil
269
- @client.temporary_credential.should == nil
270
- @client.temporary_credential_key.should == nil
271
- @client.temporary_credential_secret.should == nil
267
+ expect(@client.temporary_credential).to be_nil
268
+ expect(@client.temporary_credential_key).to be_nil
269
+ expect(@client.temporary_credential_secret).to be_nil
272
270
  end
273
271
 
274
272
  it 'should not allow the temporary_credential to be set to a bogus value' do
275
- (lambda do
273
+ expect(lambda do
276
274
  @client.temporary_credential = 42
277
- end).should raise_error(TypeError)
275
+ end).to raise_error(TypeError)
278
276
  end
279
277
 
280
278
  it 'should have no temporary_credential_key' do
281
- @client.temporary_credential_key.should == nil
279
+ expect(@client.temporary_credential_key).to be_nil
282
280
  end
283
281
 
284
282
  it 'should allow the temporary_credential_key to be set to a String' do
285
283
  @client.temporary_credential_key = "12345"
286
- @client.temporary_credential_key.should === "12345"
284
+ expect(@client.temporary_credential_key).to eq "12345"
287
285
  end
288
286
 
289
287
  it 'should not allow the temporary_credential_key ' +
290
288
  'to be set to a non-String' do
291
- (lambda do
289
+ expect(lambda do
292
290
  @client.temporary_credential_key = 12345
293
- end).should raise_error(TypeError)
291
+ end).to raise_error(TypeError)
294
292
  end
295
293
 
296
294
  it 'should have no temporary_credential_secret' do
297
- @client.temporary_credential_secret.should == nil
295
+ expect(@client.temporary_credential_secret).to be_nil
298
296
  end
299
297
 
300
298
  it 'should allow the temporary_credential_secret to be set to a String' do
301
299
  @client.temporary_credential_secret = "54321"
302
- @client.temporary_credential_secret.should === "54321"
300
+ expect(@client.temporary_credential_secret).to eq "54321"
303
301
  end
304
302
 
305
303
  it 'should not allow the temporary_credential_secret ' +
306
304
  'to be set to a non-String' do
307
- (lambda do
305
+ expect(lambda do
308
306
  @client.temporary_credential_secret = 54321
309
- end).should raise_error(TypeError)
307
+ end).to raise_error(TypeError)
310
308
  end
311
309
 
312
310
  it 'should have no token_credential' do
313
- @client.token_credential.should == nil
311
+ expect(@client.token_credential).to be_nil
314
312
  end
315
313
 
316
314
  it 'should raise an error for partially set token credentials' do
317
315
  @client.token_credential_key = "12345"
318
316
  @client.token_credential_secret = nil
319
- (lambda do
317
+ expect(lambda do
320
318
  @client.token_credential
321
- end).should raise_error(ArgumentError)
319
+ end).to raise_error(ArgumentError)
322
320
  end
323
321
 
324
322
  it 'should raise an error for partially set token credentials' do
325
323
  @client.token_credential_key = nil
326
324
  @client.token_credential_secret = "54321"
327
- (lambda do
325
+ expect(lambda do
328
326
  @client.token_credential
329
- end).should raise_error(ArgumentError)
327
+ end).to raise_error(ArgumentError)
330
328
  end
331
329
 
332
330
  it 'should allow the token_credential to be set to a ' +
333
331
  'Signet::OAuth1::Credential' do
334
332
  @client.token_credential =
335
333
  Signet::OAuth1::Credential.new("12345", "54321")
336
- @client.token_credential_key.should == "12345"
337
- @client.token_credential_secret.should == "54321"
338
- @client.token_credential.should ==
339
- Signet::OAuth1::Credential.new("12345", "54321")
334
+ expect(@client.token_credential_key).to eq "12345"
335
+ expect(@client.token_credential_secret).to eq "54321"
336
+ expect(@client.token_credential).to eq Signet::OAuth1::Credential.new("12345", "54321")
340
337
  end
341
338
 
342
339
  it 'should allow the token_credential to be set to nil' do
343
340
  @client.token_credential_key = "12345"
344
341
  @client.token_credential_secret = "54321"
345
- @client.token_credential_key.should == "12345"
346
- @client.token_credential_secret.should == "54321"
342
+ expect(@client.token_credential_key).to eq "12345"
343
+ expect(@client.token_credential_secret).to eq "54321"
347
344
  @client.token_credential = nil
348
- @client.token_credential.should == nil
349
- @client.token_credential_key.should == nil
350
- @client.token_credential_secret.should == nil
345
+ expect(@client.token_credential).to be_nil
346
+ expect(@client.token_credential_key).to be_nil
347
+ expect(@client.token_credential_secret).to be_nil
351
348
  end
352
349
 
353
350
  it 'should not allow the token_credential to be set to a bogus value' do
354
- (lambda do
351
+ expect(lambda do
355
352
  @client.token_credential = 42
356
- end).should raise_error(TypeError)
353
+ end).to raise_error(TypeError)
357
354
  end
358
355
 
359
356
  it 'should have no token_credential_key' do
360
- @client.token_credential_key.should == nil
357
+ expect(@client.token_credential_key).to be_nil
361
358
  end
362
359
 
363
360
  it 'should allow the token_credential_key to be set to a String' do
364
361
  @client.token_credential_key = "12345"
365
- @client.token_credential_key.should === "12345"
362
+ expect(@client.token_credential_key).to eq "12345"
366
363
  end
367
364
 
368
365
  it 'should not allow the token_credential_key ' +
369
366
  'to be set to a non-String' do
370
- (lambda do
367
+ expect(lambda do
371
368
  @client.token_credential_key = 12345
372
- end).should raise_error(TypeError)
369
+ end).to raise_error(TypeError)
373
370
  end
374
371
 
375
372
  it 'should have no token_credential_secret' do
376
- @client.token_credential_secret.should == nil
373
+ expect(@client.token_credential_secret).to be_nil
377
374
  end
378
375
 
379
376
  it 'should allow the token_credential_secret to be set to a String' do
380
377
  @client.token_credential_secret = "54321"
381
- @client.token_credential_secret.should === "54321"
378
+ expect(@client.token_credential_secret).to eq "54321"
382
379
  end
383
380
 
384
381
  it 'should not allow the token_credential_secret ' +
385
382
  'to be set to a non-String' do
386
- (lambda do
383
+ expect(lambda do
387
384
  @client.token_credential_secret = 54321
388
- end).should raise_error(TypeError)
385
+ end).to raise_error(TypeError)
389
386
  end
390
387
 
391
388
  it 'should not allow the two_legged flag ' +
392
389
  'to be set to a non-Boolean' do
393
- (lambda do
390
+ expect(lambda do
394
391
  @client.two_legged = 42
395
- end).should raise_error(TypeError)
392
+ end).to raise_error(TypeError)
396
393
  end
397
394
  end
398
395
 
@@ -416,43 +413,40 @@ describe Signet::OAuth1::Client, 'configured' do
416
413
 
417
414
  it 'should generate a JSON representation of the client' do
418
415
  json = @client.to_json
419
- json.should_not == nil
416
+ expect(json).not_to be_nil
420
417
 
421
418
  deserialized = MultiJson.load(json)
422
- deserialized["temporary_credential_uri"].should ==
423
- 'http://example.com/temporary_credentials'
424
- deserialized["authorization_uri"].should include(
419
+ expect(deserialized["temporary_credential_uri"]).to eq 'http://example.com/temporary_credentials'
420
+ expect(deserialized["authorization_uri"]).to include(
425
421
  'http://example.com/authorize')
426
- deserialized["token_credential_uri"].should ==
427
- 'http://example.com/token_credentials'
428
- deserialized["callback"].should == 'http://example.com/callback'
429
- deserialized["client_credential_key"].should == 'dpf43f3p2l4k3l03'
430
- deserialized["client_credential_secret"].should == 'kd94hf93k423kf44'
431
- deserialized["temporary_credential_key"].should == 'hh5s93j4hdidpola'
432
- deserialized["temporary_credential_secret"].should == 'hdhd0244k9j7ao03'
433
- deserialized["token_credential_key"].should == 'nnch734d00sl2jdk'
434
- deserialized["token_credential_secret"].should == 'pfkkdhi9sl3r4s00'
422
+ expect(deserialized["token_credential_uri"]).to eq 'http://example.com/token_credentials'
423
+ expect(deserialized["callback"]).to eq 'http://example.com/callback'
424
+ expect(deserialized["client_credential_key"]).to eq 'dpf43f3p2l4k3l03'
425
+ expect(deserialized["client_credential_secret"]).to eq 'kd94hf93k423kf44'
426
+ expect(deserialized["temporary_credential_key"]).to eq 'hh5s93j4hdidpola'
427
+ expect(deserialized["temporary_credential_secret"]).to eq 'hdhd0244k9j7ao03'
428
+ expect(deserialized["token_credential_key"]).to eq 'nnch734d00sl2jdk'
429
+ expect(deserialized["token_credential_secret"]).to eq 'pfkkdhi9sl3r4s00'
435
430
  end
436
431
 
437
432
  it 'should generate an authorization URI with a callback' do
438
433
  @client.temporary_credential_key = nil
439
- @client.authorization_uri.should ===
440
- 'http://example.com/authorize?oauth_callback=http://example.com/callback'
434
+ expect(@client.authorization_uri.to_s).to eq 'http://example.com/authorize?oauth_callback=http://example.com/callback'
441
435
  end
442
436
 
443
437
  it 'should generate an authorization URI with a temporary credential' do
444
438
  @client.callback = nil
445
- @client.authorization_uri.to_s.should include(
439
+ expect(@client.authorization_uri.to_s).to include(
446
440
  'oauth_token=hh5s93j4hdidpola'
447
441
  )
448
442
  end
449
443
 
450
444
  it 'should generate an authorization URI both a callback and ' +
451
445
  'a temporary credential' do
452
- @client.authorization_uri.to_s.should include(
446
+ expect(@client.authorization_uri.to_s).to include(
453
447
  'oauth_callback=http://example.com/callback'
454
448
  )
455
- @client.authorization_uri.to_s.should include(
449
+ expect(@client.authorization_uri.to_s).to include(
456
450
  'oauth_token=hh5s93j4hdidpola'
457
451
  )
458
452
  end
@@ -461,101 +455,101 @@ describe Signet::OAuth1::Client, 'configured' do
461
455
  authorization_uri = @client.authorization_uri(
462
456
  :additional_parameters => {:domain => 'www.example.com'}
463
457
  )
464
- authorization_uri.to_s.should include(
458
+ expect(authorization_uri.to_s).to include(
465
459
  'oauth_callback=http://example.com/callback'
466
460
  )
467
- authorization_uri.to_s.should include(
461
+ expect(authorization_uri.to_s).to include(
468
462
  'oauth_token=hh5s93j4hdidpola'
469
463
  )
470
- authorization_uri.to_s.should include(
464
+ expect(authorization_uri.to_s).to include(
471
465
  'domain=www.example.com'
472
466
  )
473
467
  end
474
468
 
475
469
  it 'should raise an error if the verifier is not provided' do
476
- (lambda do
470
+ expect(lambda do
477
471
  @client.generate_token_credential_request
478
- end).should raise_error(ArgumentError)
479
- (lambda do
472
+ end).to raise_error(ArgumentError)
473
+ expect(lambda do
480
474
  @client.generate_token_credential_request(:verifier => nil)
481
- end).should raise_error(ArgumentError)
475
+ end).to raise_error(ArgumentError)
482
476
  end
483
477
 
484
478
  it 'should raise an error if the token credentials URI is not set' do
485
479
  @client.token_credential_uri = nil
486
- (lambda do
480
+ expect(lambda do
487
481
  @client.generate_token_credential_request(:verifier => '12345')
488
- end).should raise_error(ArgumentError)
482
+ end).to raise_error(ArgumentError)
489
483
  end
490
484
 
491
485
  it 'should raise an error if the client credential key is not set' do
492
486
  @client.client_credential_key = nil
493
- (lambda do
487
+ expect(lambda do
494
488
  @client.generate_token_credential_request(:verifier => '12345')
495
- end).should raise_error(ArgumentError)
489
+ end).to raise_error(ArgumentError)
496
490
  end
497
491
 
498
492
  it 'should raise an error if the client credential secret is not set' do
499
493
  @client.client_credential_secret = nil
500
- (lambda do
494
+ expect(lambda do
501
495
  @client.generate_token_credential_request(:verifier => '12345')
502
- end).should raise_error(ArgumentError)
496
+ end).to raise_error(ArgumentError)
503
497
  end
504
498
 
505
499
  it 'should raise an error if the temporary credential key is not set' do
506
500
  @client.temporary_credential_key = nil
507
- (lambda do
501
+ expect(lambda do
508
502
  @client.generate_token_credential_request(:verifier => '12345')
509
- end).should raise_error(ArgumentError)
503
+ end).to raise_error(ArgumentError)
510
504
  end
511
505
 
512
506
  it 'should raise an error if the temporary credential secret is not set' do
513
507
  @client.temporary_credential_secret = nil
514
- (lambda do
508
+ expect(lambda do
515
509
  @client.generate_token_credential_request(:verifier => '12345')
516
- end).should raise_error(ArgumentError)
510
+ end).to raise_error(ArgumentError)
517
511
  end
518
512
 
519
513
  it 'should raise an error if the client credential key is not set' do
520
514
  @client.client_credential_key = nil
521
- (lambda do
515
+ expect(lambda do
522
516
  @client.generate_authenticated_request
523
- end).should raise_error(ArgumentError)
517
+ end).to raise_error(ArgumentError)
524
518
  end
525
519
 
526
520
  it 'should raise an error if the client credential secret is not set' do
527
521
  @client.client_credential_secret = nil
528
- (lambda do
522
+ expect(lambda do
529
523
  @client.generate_authenticated_request
530
- end).should raise_error(ArgumentError)
524
+ end).to raise_error(ArgumentError)
531
525
  end
532
526
 
533
527
  it 'should raise an error if the token credential key is not set' do
534
528
  @client.token_credential_key = nil
535
- (lambda do
529
+ expect(lambda do
536
530
  @client.generate_authenticated_request
537
- end).should raise_error(ArgumentError)
531
+ end).to raise_error(ArgumentError)
538
532
  end
539
533
 
540
534
  it 'should raise an error if the token credential secret is not set' do
541
535
  @client.token_credential_secret = nil
542
- (lambda do
536
+ expect(lambda do
543
537
  @client.generate_authenticated_request
544
- end).should raise_error(ArgumentError)
538
+ end).to raise_error(ArgumentError)
545
539
  end
546
540
 
547
541
  it 'should raise an error if no request is provided' do
548
- (lambda do
542
+ expect(lambda do
549
543
  @client.generate_authenticated_request
550
- end).should raise_error(ArgumentError)
544
+ end).to raise_error(ArgumentError)
551
545
  end
552
546
 
553
547
  it 'should raise an error if a bogus request is provided' do
554
- (lambda do
548
+ expect(lambda do
555
549
  @client.generate_authenticated_request(
556
550
  :request => []
557
551
  )
558
- end).should raise_error
552
+ end).to raise_error
559
553
  end
560
554
 
561
555
  it 'should not raise an error if a request is ' +
@@ -568,13 +562,13 @@ describe Signet::OAuth1::Client, 'configured' do
568
562
  end
569
563
 
570
564
  it 'should raise an error if no URI is provided' do
571
- (lambda do
565
+ expect(lambda do
572
566
  @client.generate_authenticated_request(
573
567
  :method => 'GET',
574
568
  :headers => [],
575
569
  :body => ''
576
570
  )
577
- end).should raise_error(ArgumentError)
571
+ end).to raise_error(ArgumentError)
578
572
  end
579
573
 
580
574
  it 'should not raise an error if a request body is chunked' do
@@ -583,8 +577,8 @@ describe Signet::OAuth1::Client, 'configured' do
583
577
  :uri => 'https://photos.example.net/photos',
584
578
  :body => ['A chunked body.']
585
579
  )
586
- request.should be_kind_of(Faraday::Request)
587
- request.body.should == 'A chunked body.'
580
+ expect(request).to be_kind_of(Faraday::Request)
581
+ expect(request.body).to eq 'A chunked body.'
588
582
  end
589
583
 
590
584
  it 'should not raise an error if a request body is chunked' do
@@ -596,40 +590,40 @@ describe Signet::OAuth1::Client, 'configured' do
596
590
  :uri => 'https://photos.example.net/photos',
597
591
  :body => chunked_body
598
592
  )
599
- request.should be_kind_of(Faraday::Request)
600
- request.body.should == 'A chunked body.'
593
+ expect(request).to be_kind_of(Faraday::Request)
594
+ expect(request.body).to eq 'A chunked body.'
601
595
  end
602
596
 
603
597
  it 'should raise an error if a request body is of a bogus type' do
604
- (lambda do
598
+ expect(lambda do
605
599
  @client.generate_authenticated_request(
606
600
  :method => 'POST',
607
601
  :uri => 'https://photos.example.net/photos',
608
602
  :body => 42
609
603
  )
610
- end).should raise_error(TypeError)
604
+ end).to raise_error(TypeError)
611
605
  end
612
606
 
613
607
  it 'should correctly fetch the temporary credentials' do
614
608
  # Repeat this because signatures change from test to test
615
609
  10.times do
616
610
  request = @client.generate_temporary_credential_request
617
- request.method.should == :post
618
- request.path.should === 'http://example.com/temporary_credentials'
611
+ expect(request.method).to eq :post
612
+ expect(request.path).to eq 'http://example.com/temporary_credentials'
619
613
  authorization_header = request.headers['Authorization']
620
614
  parameters = ::Signet::OAuth1.parse_authorization_header(
621
615
  authorization_header
622
616
  ).inject({}) { |h,(k,v)| h[k]=v; h }
623
- parameters.should_not have_key('oauth_client_credential_key')
624
- parameters.should_not have_key('oauth_temporary_credential_key')
625
- parameters.should_not have_key('oauth_token')
626
- parameters['oauth_nonce'].should =~ /^\w+$/
627
- parameters['oauth_callback'].should == @client.callback
628
- parameters['oauth_timestamp'].should =~ /^\d+$/
629
- parameters['oauth_signature_method'].should == 'HMAC-SHA1'
630
- parameters['oauth_consumer_key'].should == @client.client_credential_key
631
- parameters['oauth_signature'].should =~ /^[a-zA-Z0-9\=\/\+]+$/
632
- parameters['oauth_version'].should == '1.0'
617
+ expect(parameters).not_to have_key('oauth_client_credential_key')
618
+ expect(parameters).not_to have_key('oauth_temporary_credential_key')
619
+ expect(parameters).not_to have_key('oauth_token')
620
+ expect(parameters['oauth_nonce']).to match(/^\w+$/)
621
+ expect(parameters['oauth_callback']).to eq @client.callback
622
+ expect(parameters['oauth_timestamp']).to match(/^\d+$/)
623
+ expect(parameters['oauth_signature_method']).to eq 'HMAC-SHA1'
624
+ expect(parameters['oauth_consumer_key']).to eq @client.client_credential_key
625
+ expect(parameters['oauth_signature']).to match(/^[a-zA-Z0-9\=\/\+]+$/)
626
+ expect(parameters['oauth_version']).to eq '1.0'
633
627
  end
634
628
  end
635
629
 
@@ -639,23 +633,23 @@ describe Signet::OAuth1::Client, 'configured' do
639
633
  request = @client.generate_token_credential_request(
640
634
  :verifier => '473f82d3'
641
635
  )
642
- request.method.should == :post
643
- request.path.should === 'http://example.com/token_credentials'
636
+ expect(request.method).to eq :post
637
+ expect(request.path).to eq 'http://example.com/token_credentials'
644
638
  authorization_header = request.headers['Authorization']
645
639
  parameters = ::Signet::OAuth1.parse_authorization_header(
646
640
  authorization_header
647
641
  ).inject({}) { |h,(k,v)| h[k]=v; h }
648
- parameters.should_not have_key('oauth_client_credential_key')
649
- parameters.should_not have_key('oauth_temporary_credential_key')
650
- parameters.should_not have_key('oauth_callback')
651
- parameters['oauth_nonce'].should =~ /^\w+$/
652
- parameters['oauth_timestamp'].should =~ /^\d+$/
653
- parameters['oauth_signature_method'].should == 'HMAC-SHA1'
654
- parameters['oauth_consumer_key'].should == @client.client_credential_key
655
- parameters['oauth_token'].should == @client.temporary_credential_key
656
- parameters['oauth_signature'].should =~ /^[a-zA-Z0-9\=\/\+]+$/
657
- parameters['oauth_verifier'].should == '473f82d3'
658
- parameters['oauth_version'].should == '1.0'
642
+ expect(parameters).not_to have_key('oauth_client_credential_key')
643
+ expect(parameters).not_to have_key('oauth_temporary_credential_key')
644
+ expect(parameters).not_to have_key('oauth_callback')
645
+ expect(parameters['oauth_nonce']).to match(/^\w+$/)
646
+ expect(parameters['oauth_timestamp']).to match(/^\d+$/)
647
+ expect(parameters['oauth_signature_method']).to eq 'HMAC-SHA1'
648
+ expect(parameters['oauth_consumer_key']).to eq @client.client_credential_key
649
+ expect(parameters['oauth_token']).to eq @client.temporary_credential_key
650
+ expect(parameters['oauth_signature']).to match(/^[a-zA-Z0-9\=\/\+]+$/)
651
+ expect(parameters['oauth_verifier']).to eq '473f82d3'
652
+ expect(parameters['oauth_version']).to eq '1.0'
659
653
  end
660
654
  end
661
655
 
@@ -671,27 +665,25 @@ describe Signet::OAuth1::Client, 'configured' do
671
665
  signed_request = @client.generate_authenticated_request(
672
666
  :request => original_request
673
667
  )
674
- signed_request.method.should == :get
675
- signed_request.path.should ===
676
- 'https://photos.example.net/photos'
677
- signed_request.params.should ==
678
- {"file"=>"vacation.jpg", "size"=>"original"}
668
+ expect(signed_request.method).to eq :get
669
+ expect(signed_request.path).to eq 'https://photos.example.net/photos'
670
+ expect(signed_request.params).to eq({"file"=>"vacation.jpg", "size"=>"original"})
679
671
  authorization_header = signed_request.headers['Authorization']
680
- signed_request.body.should == ''
672
+ expect(signed_request.body).to eq ''
681
673
  parameters = ::Signet::OAuth1.parse_authorization_header(
682
674
  authorization_header
683
675
  ).inject({}) { |h,(k,v)| h[k]=v; h }
684
- parameters.should_not have_key('oauth_client_credential_key')
685
- parameters.should_not have_key('oauth_temporary_credential_key')
686
- parameters.should_not have_key('oauth_token_credential_key')
687
- parameters.should_not have_key('oauth_callback')
688
- parameters['oauth_nonce'].should =~ /^\w+$/
689
- parameters['oauth_timestamp'].should =~ /^\d+$/
690
- parameters['oauth_signature_method'].should == 'HMAC-SHA1'
691
- parameters['oauth_consumer_key'].should == @client.client_credential_key
692
- parameters['oauth_token'].should == @client.token_credential_key
693
- parameters['oauth_signature'].should =~ /^[a-zA-Z0-9\=\/\+]+$/
694
- parameters['oauth_version'].should == '1.0'
676
+ expect(parameters).not_to have_key('oauth_client_credential_key')
677
+ expect(parameters).not_to have_key('oauth_temporary_credential_key')
678
+ expect(parameters).not_to have_key('oauth_token_credential_key')
679
+ expect(parameters).not_to have_key('oauth_callback')
680
+ expect(parameters['oauth_nonce']).to match(/^\w+$/)
681
+ expect(parameters['oauth_timestamp']).to match(/^\d+$/)
682
+ expect(parameters['oauth_signature_method']).to eq 'HMAC-SHA1'
683
+ expect(parameters['oauth_consumer_key']).to eq @client.client_credential_key
684
+ expect(parameters['oauth_token']).to eq @client.token_credential_key
685
+ expect(parameters['oauth_signature']).to match(/^[a-zA-Z0-9\=\/\+]+$/)
686
+ expect(parameters['oauth_version']).to eq '1.0'
695
687
  end
696
688
  end
697
689
 
@@ -711,25 +703,24 @@ describe Signet::OAuth1::Client, 'configured' do
711
703
  signed_request = @client.generate_authenticated_request(
712
704
  :request => original_request
713
705
  )
714
- signed_request.method.should == :post
715
- signed_request.path.should ===
716
- 'https://photos.example.net/photos'
706
+ expect(signed_request.method).to eq :post
707
+ expect(signed_request.path).to eq 'https://photos.example.net/photos'
717
708
  authorization_header = signed_request.headers['Authorization']
718
- signed_request.body.should == 'file=vacation.jpg&size=original'
709
+ expect(signed_request.body).to eq 'file=vacation.jpg&size=original'
719
710
  parameters = ::Signet::OAuth1.parse_authorization_header(
720
711
  authorization_header
721
712
  ).inject({}) { |h,(k,v)| h[k]=v; h }
722
- parameters.should_not have_key('oauth_client_credential_key')
723
- parameters.should_not have_key('oauth_temporary_credential_key')
724
- parameters.should_not have_key('oauth_token_credential_key')
725
- parameters.should_not have_key('oauth_callback')
726
- parameters['oauth_nonce'].should =~ /^\w+$/
727
- parameters['oauth_timestamp'].should =~ /^\d+$/
728
- parameters['oauth_signature_method'].should == 'HMAC-SHA1'
729
- parameters['oauth_consumer_key'].should == @client.client_credential_key
730
- parameters['oauth_token'].should == @client.token_credential_key
731
- parameters['oauth_signature'].should =~ /^[a-zA-Z0-9\=\/\+]+$/
732
- parameters['oauth_version'].should == '1.0'
713
+ expect(parameters).not_to have_key('oauth_client_credential_key')
714
+ expect(parameters).not_to have_key('oauth_temporary_credential_key')
715
+ expect(parameters).not_to have_key('oauth_token_credential_key')
716
+ expect(parameters).not_to have_key('oauth_callback')
717
+ expect(parameters['oauth_nonce']).to match(/^\w+$/)
718
+ expect(parameters['oauth_timestamp']).to match(/^\d+$/)
719
+ expect(parameters['oauth_signature_method']).to eq 'HMAC-SHA1'
720
+ expect(parameters['oauth_consumer_key']).to eq @client.client_credential_key
721
+ expect(parameters['oauth_token']).to eq @client.token_credential_key
722
+ expect(parameters['oauth_signature']).to match(/^[a-zA-Z0-9\=\/\+]+$/)
723
+ expect(parameters['oauth_version']).to eq '1.0'
733
724
  end
734
725
  end
735
726
 
@@ -753,29 +744,27 @@ describe Signet::OAuth1::Client, 'configured' do
753
744
  )
754
745
 
755
746
  # Should be same request object
756
- original_request['Authorization'].should == signed_request['Authorization']
747
+ expect(original_request['Authorization']).to eq signed_request['Authorization']
757
748
 
758
- signed_request.method.should == :get
759
- signed_request.path.should ===
760
- 'https://photos.example.net/photos'
761
- signed_request.params.should ===
762
- {"file"=>"vacation.jpg", "size"=>"original"}
749
+ expect(signed_request.method).to eq :get
750
+ expect(signed_request.path).to eq 'https://photos.example.net/photos'
751
+ expect(signed_request.params).to eq ({"file"=>"vacation.jpg", "size"=>"original"})
763
752
  authorization_header = signed_request.headers['Authorization']
764
- signed_request.body.should == ''
753
+ expect(signed_request.body).to eq ''
765
754
  parameters = ::Signet::OAuth1.parse_authorization_header(
766
755
  authorization_header
767
756
  ).inject({}) { |h,(k,v)| h[k]=v; h }
768
- parameters.should_not have_key('oauth_client_credential_key')
769
- parameters.should_not have_key('oauth_temporary_credential_key')
770
- parameters.should_not have_key('oauth_token_credential_key')
771
- parameters.should_not have_key('oauth_callback')
772
- parameters['oauth_nonce'].should =~ /^\w+$/
773
- parameters['oauth_timestamp'].should =~ /^\d+$/
774
- parameters['oauth_signature_method'].should == 'HMAC-SHA1'
775
- parameters['oauth_consumer_key'].should == @client.client_credential_key
776
- parameters['oauth_token'].should == @client.token_credential_key
777
- parameters['oauth_signature'].should =~ /^[a-zA-Z0-9\=\/\+]+$/
778
- parameters['oauth_version'].should == '1.0'
757
+ expect(parameters).not_to have_key('oauth_client_credential_key')
758
+ expect(parameters).not_to have_key('oauth_temporary_credential_key')
759
+ expect(parameters).not_to have_key('oauth_token_credential_key')
760
+ expect(parameters).not_to have_key('oauth_callback')
761
+ expect(parameters['oauth_nonce']).to match(/^\w+$/)
762
+ expect(parameters['oauth_timestamp']).to match(/^\d+$/)
763
+ expect(parameters['oauth_signature_method']).to eq 'HMAC-SHA1'
764
+ expect(parameters['oauth_consumer_key']).to eq @client.client_credential_key
765
+ expect(parameters['oauth_token']).to eq @client.token_credential_key
766
+ expect(parameters['oauth_signature']).to match(/^[a-zA-Z0-9\=\/\+]+$/)
767
+ expect(parameters['oauth_version']).to eq '1.0'
779
768
  end
780
769
  end
781
770
 
@@ -800,29 +789,28 @@ describe Signet::OAuth1::Client, 'configured' do
800
789
  )
801
790
 
802
791
  # Should be same request object
803
- original_request['Authorization'].should == signed_request['Authorization']
792
+ expect(original_request['Authorization']).to eq signed_request['Authorization']
804
793
 
805
- signed_request.method.should == :post
806
- signed_request.path.should ===
807
- 'https://photos.example.net/photos'
794
+ expect(signed_request.method).to eq :post
795
+ expect(signed_request.path).to eq 'https://photos.example.net/photos'
808
796
  authorization_header = signed_request.headers['Authorization']
809
797
  # Can't rely on the order post parameters are encoded in.
810
- signed_request.body.should include('file=vacation.jpg')
811
- signed_request.body.should include('size=original')
798
+ expect(signed_request.body).to include('file=vacation.jpg')
799
+ expect(signed_request.body).to include('size=original')
812
800
  parameters = ::Signet::OAuth1.parse_authorization_header(
813
801
  authorization_header
814
802
  ).inject({}) { |h,(k,v)| h[k]=v; h }
815
- parameters.should_not have_key('oauth_client_credential_key')
816
- parameters.should_not have_key('oauth_temporary_credential_key')
817
- parameters.should_not have_key('oauth_token_credential_key')
818
- parameters.should_not have_key('oauth_callback')
819
- parameters['oauth_nonce'].should =~ /^\w+$/
820
- parameters['oauth_timestamp'].should =~ /^\d+$/
821
- parameters['oauth_signature_method'].should == 'HMAC-SHA1'
822
- parameters['oauth_consumer_key'].should == @client.client_credential_key
823
- parameters['oauth_token'].should == @client.token_credential_key
824
- parameters['oauth_signature'].should =~ /^[a-zA-Z0-9\=\/\+]+$/
825
- parameters['oauth_version'].should == '1.0'
803
+ expect(parameters).not_to have_key('oauth_client_credential_key')
804
+ expect(parameters).not_to have_key('oauth_temporary_credential_key')
805
+ expect(parameters).not_to have_key('oauth_token_credential_key')
806
+ expect(parameters).not_to have_key('oauth_callback')
807
+ expect(parameters['oauth_nonce']).to match(/^\w+$/)
808
+ expect(parameters['oauth_timestamp']).to match(/^\d+$/)
809
+ expect(parameters['oauth_signature_method']).to eq 'HMAC-SHA1'
810
+ expect(parameters['oauth_consumer_key']).to eq @client.client_credential_key
811
+ expect(parameters['oauth_token']).to eq @client.token_credential_key
812
+ expect(parameters['oauth_signature']).to match(/^[a-zA-Z0-9\=\/\+]+$/)
813
+ expect(parameters['oauth_version']).to eq '1.0'
826
814
  end
827
815
  end
828
816
  end