signet 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -79,16 +79,16 @@ describe Signet::OAuth1::Server, 'unconfigured' do
79
79
  @server = Signet::OAuth1::Server.new
80
80
  end
81
81
  it 'should not have a client_credential Proc' do
82
- @server.client_credential.should == nil
82
+ expect(@server.client_credential).to eq nil
83
83
  end
84
84
  it 'should not have a token_credential Proc' do
85
- @server.token_credential.should == nil
85
+ expect(@server.token_credential).to eq nil
86
86
  end
87
87
  it 'should not have a nonce_timestamp Proc' do
88
- @server.nonce_timestamp.should == nil
88
+ expect(@server.nonce_timestamp).to eq nil
89
89
  end
90
90
  it 'should not have a verifier Proc' do
91
- @server.verifier.should == nil
91
+ expect(@server.verifier).to eq nil
92
92
  end
93
93
  end
94
94
 
@@ -128,76 +128,76 @@ describe Signet::OAuth1::Server, 'configured' do
128
128
 
129
129
  it 'should raise an error if the client credential Proc is not set' do
130
130
  @server.client_credential = nil
131
- (lambda do
131
+ expect(lambda do
132
132
  @server.authenticate_resource_request
133
- end).should raise_error(ArgumentError)
133
+ end).to raise_error(ArgumentError)
134
134
  end
135
135
 
136
136
  it "should raise an error if the token credential Proc is not set" do
137
137
  @server.token_credential = nil
138
- (lambda do
138
+ expect(lambda do
139
139
  @server.authenticate_resource_request
140
- end).should raise_error(ArgumentError)
140
+ end).to raise_error(ArgumentError)
141
141
  end
142
142
 
143
143
  it "should raise an error if the temporary token credential Proc is not set" do
144
144
  @server.temporary_credential = nil
145
- (lambda do
145
+ expect(lambda do
146
146
  @server.authenticate_token_credential_request
147
- end).should raise_error(ArgumentError)
147
+ end).to raise_error(ArgumentError)
148
148
  end
149
149
 
150
150
  it "should raise an error if the verifier Proc is not set for a token request" do
151
151
  @server.verifier = nil
152
- (lambda do
152
+ expect(lambda do
153
153
  @server.authenticate_token_credential_request
154
- end).should raise_error(ArgumentError)
154
+ end).to raise_error(ArgumentError)
155
155
  end
156
156
 
157
157
  it 'should raise an error if no request is provided' do
158
- (lambda do
158
+ expect(lambda do
159
159
  @server.authenticate_resource_request
160
- end).should raise_error(ArgumentError)
160
+ end).to raise_error(ArgumentError)
161
161
  end
162
162
 
163
163
  it 'should raise an error if a bogus request is provided' do
164
- (lambda do
164
+ expect(lambda do
165
165
  @server.authenticate_resource_request(
166
166
  :request => []
167
167
  )
168
- end).should raise_error(ArgumentError)
168
+ end).to raise_error(ArgumentError)
169
169
  end
170
170
 
171
171
  it 'should raise an error if no Authentication header is provided' do
172
- (lambda do
172
+ expect(lambda do
173
173
  @server.authenticate_resource_request(
174
174
  :method => 'GET',
175
175
  :uri => 'https://photos.example.net/photos',
176
176
  :headers => [['Authorization', '']],
177
177
  :body => ''
178
178
  )
179
- end).should raise_error(Signet::MalformedAuthorizationError)
179
+ end).to raise_error(Signet::MalformedAuthorizationError)
180
180
  end
181
181
 
182
182
  it 'should raise an error if no URI is provided' do
183
- (lambda do
183
+ expect(lambda do
184
184
  @server.authenticate_resource_request(
185
185
  :method => 'GET',
186
186
  :headers => [],
187
187
  :body => ''
188
188
  )
189
- end).should raise_error(ArgumentError)
189
+ end).to raise_error(ArgumentError)
190
190
  end
191
191
 
192
192
  it 'should reject a request with the wrong signature method' do
193
193
  bad_method = 'FOO'
194
- (lambda do
194
+ expect(lambda do
195
195
  @server.authenticate_resource_request(
196
196
  :method => 'GET',
197
197
  :uri => 'http://photos.example.net/photos',
198
198
  :headers=>make_oauth_token_header({'oauth_signature_method'=>bad_method})
199
199
  )
200
- end).should raise_error(NotImplementedError,
200
+ end).to raise_error(NotImplementedError,
201
201
  "Unsupported signature method: #{bad_method}"
202
202
  )
203
203
  end
@@ -211,18 +211,18 @@ describe Signet::OAuth1::Server, 'configured' do
211
211
  @temporary_credential_key, @temporary_credential_secret
212
212
  )
213
213
  end
214
- @server.find_temporary_credential(@temporary_credential_key).should ==
214
+ expect(@server.find_temporary_credential(@temporary_credential_key)).to eq(
215
215
  Signet::OAuth1::Credential.new(@temporary_credential_key,
216
- @temporary_credential_secret)
216
+ @temporary_credential_secret))
217
217
  end
218
218
  it 'should return a Signet credential if the Proc provides a key/secret pair' do
219
219
  @server.temporary_credential =
220
220
  lambda do |x|
221
221
  {:key=>@temporary_credential_key, :secret=>@temporary_credential_secret}
222
222
  end
223
- @server.find_temporary_credential(@temporary_credential_key).should ==
223
+ expect(@server.find_temporary_credential(@temporary_credential_key)).to eq(
224
224
  Signet::OAuth1::Credential.new(@temporary_credential_key,
225
- @temporary_credential_secret)
225
+ @temporary_credential_secret))
226
226
  end
227
227
  it 'should return a Signet credential if the Proc provides ' +
228
228
  'a key/secret Enumerable' do
@@ -230,15 +230,14 @@ describe Signet::OAuth1::Server, 'configured' do
230
230
  lambda do |x|
231
231
  [@temporary_credential_key, @temporary_credential_secret]
232
232
  end
233
- @server.find_temporary_credential(@temporary_credential_key).should ==
233
+ expect(@server.find_temporary_credential(@temporary_credential_key)).to eq(
234
234
  Signet::OAuth1::Credential.new(@temporary_credential_key,
235
- @temporary_credential_secret
236
- )
235
+ @temporary_credential_secret))
237
236
  end
238
237
 
239
238
  it 'should return nil if the Proc does not provide a usable response' do
240
239
  @server.temporary_credential = lambda {|x| nil }
241
- @server.find_temporary_credential(@temporary_credential_key).should == nil
240
+ expect(@server.find_temporary_credential(@temporary_credential_key)).to eq nil
242
241
  end
243
242
  end
244
243
 
@@ -250,18 +249,18 @@ describe Signet::OAuth1::Server, 'configured' do
250
249
  x.nil? ? nil : Signet::OAuth1::Credential.new(@client_credential_key,
251
250
  @client_credential_secret)
252
251
  end
253
- @server.find_client_credential(@client_credential_key).should ==
252
+ expect(@server.find_client_credential(@client_credential_key)).to eq(
254
253
  Signet::OAuth1::Credential.new(@client_credential_key,
255
- @client_credential_secret)
254
+ @client_credential_secret))
256
255
  end
257
256
  it 'should return a Signet credential if the Proc provides a key/secret pair' do
258
257
  @server.client_credential =
259
258
  lambda do |x|
260
259
  {:key=>@client_credential_key, :secret=>@client_credential_secret}
261
260
  end
262
- @server.find_client_credential(@client_credential_key).should ==
261
+ expect(@server.find_client_credential(@client_credential_key)).to eq(
263
262
  Signet::OAuth1::Credential.new(@client_credential_key,
264
- @client_credential_secret)
263
+ @client_credential_secret))
265
264
  end
266
265
  it 'should return a Signet credential if the Proc provides ' +
267
266
  'a key/secret Enumerable' do
@@ -269,14 +268,14 @@ describe Signet::OAuth1::Server, 'configured' do
269
268
  lambda do |x|
270
269
  [@client_credential_key, @client_credential_secret]
271
270
  end
272
- @server.find_client_credential(@client_credential_key).should ==
271
+ expect(@server.find_client_credential(@client_credential_key)).to eq(
273
272
  Signet::OAuth1::Credential.new(@client_credential_key,
274
- @client_credential_secret)
273
+ @client_credential_secret))
275
274
  end
276
275
 
277
276
  it 'should return nil if the Proc does not provide a usable response' do
278
277
  @server.client_credential = lambda {|x| nil }
279
- @server.find_client_credential(@client_credential_key).should == nil
278
+ expect(@server.find_client_credential(@client_credential_key)).to be_nil
280
279
  end
281
280
  end
282
281
 
@@ -288,9 +287,9 @@ describe Signet::OAuth1::Server, 'configured' do
288
287
  x.nil? ? nil : Signet::OAuth1::Credential.new(@token_credential_key,
289
288
  @token_credential_secret)
290
289
  end
291
- @server.find_token_credential(@token_credential_key).should ==
290
+ expect(@server.find_token_credential(@token_credential_key)).to eq(
292
291
  Signet::OAuth1::Credential.new(@token_credential_key,
293
- @token_credential_secret)
292
+ @token_credential_secret))
294
293
  end
295
294
 
296
295
  it 'should return a Signet credential if the Proc provides a key/secret pair' do
@@ -298,9 +297,9 @@ describe Signet::OAuth1::Server, 'configured' do
298
297
  lambda do |x|
299
298
  {:key=>@token_credential_key, :secret=>@token_credential_secret}
300
299
  end
301
- @server.find_token_credential(@token_credential_key).should ==
300
+ expect(@server.find_token_credential(@token_credential_key)).to eq(
302
301
  Signet::OAuth1::Credential.new(@token_credential_key,
303
- @token_credential_secret)
302
+ @token_credential_secret))
304
303
  end
305
304
 
306
305
  it 'should return a Signet credential if the Proc provides ' +
@@ -309,14 +308,14 @@ describe Signet::OAuth1::Server, 'configured' do
309
308
  lambda do |x|
310
309
  [@token_credential_key, @token_credential_secret]
311
310
  end
312
- @server.find_token_credential(@token_credential_key).should ==
311
+ expect(@server.find_token_credential(@token_credential_key)).to eq(
313
312
  Signet::OAuth1::Credential.new(@token_credential_key,
314
- @token_credential_secret)
313
+ @token_credential_secret))
315
314
  end
316
315
 
317
316
  it 'should return nil if the Proc does not provide a usable response' do
318
317
  @server.token_credential = lambda {|x| nil }
319
- @server.find_token_credential(@token_credential_key).should == nil
318
+ expect(@server.find_token_credential(@token_credential_key)).to be_nil
320
319
  end
321
320
  end
322
321
 
@@ -324,30 +323,30 @@ describe Signet::OAuth1::Server, 'configured' do
324
323
  describe 'calling find_verifier' do
325
324
  it 'should return false if server verifier returns false' do
326
325
  @server.verifier = lambda {|x| false }
327
- @server.find_verifier(@verifier).should == false
326
+ expect(@server.find_verifier(@verifier)).to eq false
328
327
  end
329
328
  it 'should return false if server verifier returns nil' do
330
329
  @server.verifier = lambda {|x| nil }
331
- @server.find_verifier(@verifier).should == false
330
+ expect(@server.find_verifier(@verifier)).to eq false
332
331
  end
333
332
  it 'should return true if server verifier returns a random object' do
334
333
  @server.verifier = lambda {|x| x.succ}
335
- @server.find_verifier(@verifier).should == true
334
+ expect(@server.find_verifier(@verifier)).to eq true
336
335
  end
337
336
  end
338
337
 
339
338
  describe 'calling validate_nonce_timestamp' do
340
339
  it 'should return false if nonce_timestamp Proc returns false' do
341
340
  @server.nonce_timestamp = lambda {|n,t| false}
342
- @server.validate_nonce_timestamp('nonce', 'timestamp'). should == false
341
+ expect(@server.validate_nonce_timestamp('nonce', 'timestamp')).to be false
343
342
  end
344
343
  it 'should return false if nonce_timestamp Proc returns nil' do
345
344
  @server.nonce_timestamp = lambda {|n,t| nil}
346
- @server.validate_nonce_timestamp('nonce', 'timestamp'). should == false
345
+ expect(@server.validate_nonce_timestamp('nonce', 'timestamp')).to be false
347
346
  end
348
347
  it 'should return true if nonce_timestamp Proc returns a random object' do
349
348
  @server.nonce_timestamp = lambda {|n,t| n+t.to_s}
350
- @server.validate_nonce_timestamp('nonce', 'timestamp'). should == true
349
+ expect(@server.validate_nonce_timestamp('nonce', 'timestamp')).to be true
351
350
  end
352
351
  end
353
352
 
@@ -363,25 +362,25 @@ describe Signet::OAuth1::Server, 'configured' do
363
362
 
364
363
  it 'should raise an error if the client credential Proc is not set' do
365
364
  @server.client_credential = nil
366
- (lambda do
365
+ expect(lambda do
367
366
  @server.authenticate_temporary_credential_request(
368
367
  :request=>make_temporary_credential_request(@client)
369
368
  )
370
- end).should raise_error(ArgumentError)
369
+ end).to raise_error(ArgumentError)
371
370
  end
372
371
  it 'should reject an malformed request' do
373
372
  bad_request = make_temporary_credential_request(@client, nil, 'https://photos.example.net/photos')
374
373
  bad_request.headers['Authorization'].gsub!(/(OAuth)(.+)/, "#{$1}")
375
- (lambda do
374
+ expect(lambda do
376
375
  @server.authenticate_temporary_credential_request(
377
376
  :request=>bad_request
378
377
  )
379
- end).should raise_error(Signet::MalformedAuthorizationError)
378
+ end).to raise_error(Signet::MalformedAuthorizationError)
380
379
  end
381
380
 
382
381
  it 'should call a user-supplied Proc to validate a nonce/timestamp pair' do
383
- nonce_callback = mock('nonce')
384
- nonce_callback.should_receive(:call).once.with(an_instance_of(String),
382
+ nonce_callback = double('nonce')
383
+ expect(nonce_callback).to receive(:call).once.with(an_instance_of(String),
385
384
  an_instance_of(String)
386
385
  ).and_return(true)
387
386
 
@@ -393,44 +392,44 @@ describe Signet::OAuth1::Server, 'configured' do
393
392
 
394
393
  it "should return 'oob' for a valid request without an oauth_callback" do
395
394
  bad_request = make_temporary_credential_request(@client)
396
- @server.authenticate_temporary_credential_request(
395
+ expect(@server.authenticate_temporary_credential_request(
397
396
  :request=>bad_request
398
- ).should == 'oob'
397
+ )).to eq 'oob'
399
398
  end
400
399
  it 'should return the oauth_callback for a valid request ' +
401
400
  'with an oauth_callback' do
402
401
  callback = 'http://printer.example.com/ready'
403
- @server.authenticate_temporary_credential_request(
402
+ expect(@server.authenticate_temporary_credential_request(
404
403
  :request=>make_temporary_credential_request(@client, callback)
405
- ).should == callback
404
+ )).to eq callback
406
405
  end
407
406
  it 'should return false for an unauthenticated request' do
408
407
  bad_request = make_temporary_credential_request(@client)
409
408
  bad_request.headers["Authorization"].gsub!(/oauth_signature=\".+\"/,
410
409
  "oauth_signature=\"foobar\"")
411
- @server.authenticate_temporary_credential_request(
410
+ expect(@server.authenticate_temporary_credential_request(
412
411
  :request=>bad_request
413
- ).should == false
412
+ )).to eq false
414
413
  end
415
414
  it 'should return nil from #request_realm if no realm is provided' do
416
415
  req = make_temporary_credential_request(@client)
417
- @server.request_realm(
416
+ expect(@server.request_realm(
418
417
  :request=>req
419
- ).should == nil
418
+ )).to eq nil
420
419
  end
421
420
 
422
421
  describe 'with a Realm provided' do
423
422
  it 'should return the realm from #request_realm' do
424
423
  req = make_temporary_credential_request(@client, nil, nil, 'Photos')
425
- @server.request_realm(
424
+ expect(@server.request_realm(
426
425
  :request=>req
427
- ).should == 'Photos'
426
+ )).to eq 'Photos'
428
427
  end
429
428
  it 'should return "oob" with a valid request without an oauth_callback' do
430
429
  req = make_temporary_credential_request(@client, nil, nil, 'Photos')
431
- @server.authenticate_temporary_credential_request(
430
+ expect(@server.authenticate_temporary_credential_request(
432
431
  :request=>req
433
- ).should == 'oob'
432
+ )).to eq 'oob'
434
433
  end
435
434
  end
436
435
 
@@ -456,15 +455,15 @@ describe Signet::OAuth1::Server, 'configured' do
456
455
  bad_request = make_token_credential_request(@client)
457
456
  bad_request.headers["Authorization"].gsub!(/(OAuth)(.+)/, "#{$1}")
458
457
 
459
- (lambda do
458
+ expect(lambda do
460
459
  @server.authenticate_token_credential_request(
461
460
  :request=>bad_request
462
461
  )
463
- end).should raise_error(Signet::MalformedAuthorizationError)
462
+ end).to raise_error(Signet::MalformedAuthorizationError)
464
463
  end
465
464
  it 'should call a user-supplied Proc to validate a nonce/timestamp pair' do
466
- nonce_callback = mock('nonce')
467
- nonce_callback.should_receive(:call).once.with(
465
+ nonce_callback = double('nonce')
466
+ expect(nonce_callback).to receive(:call).once.with(
468
467
  an_instance_of(String), an_instance_of(String)
469
468
  ).and_return(true)
470
469
  @server.nonce_timestamp = nonce_callback
@@ -473,23 +472,23 @@ describe Signet::OAuth1::Server, 'configured' do
473
472
  )
474
473
  end
475
474
  it 'should return an informational hash for a valid request' do
476
- @server.authenticate_token_credential_request(
475
+ expect(@server.authenticate_token_credential_request(
477
476
  :request=>make_token_credential_request(@client)
478
- ).should == @return_hash
477
+ )).to eq @return_hash
479
478
  end
480
479
  it 'should return nil for an unauthenticated request' do
481
480
  bad_request = make_token_credential_request(@client)
482
481
  bad_request.headers["Authorization"].gsub!(/oauth_signature=\".+\"/,
483
482
  "oauth_signature=\"foobar\"")
484
- @server.authenticate_token_credential_request(
483
+ expect(@server.authenticate_token_credential_request(
485
484
  :request=>bad_request
486
- ).should == nil
485
+ )).to eq nil
487
486
  end
488
487
  it 'should call a user-supplied Proc to fetch the client credential' do
489
488
  client_cred = Signet::OAuth1::Credential.new(@client_credential_key,
490
489
  @client_credential_secret )
491
- key_callback = mock('client_cred')
492
- key_callback.should_receive(:call).at_least(:once).with(
490
+ key_callback = double('client_cred')
491
+ expect(key_callback).to receive(:call).at_least(:once).with(
493
492
  @client_credential_key
494
493
  ).and_return(client_cred)
495
494
 
@@ -502,8 +501,8 @@ describe Signet::OAuth1::Server, 'configured' do
502
501
  it 'should call a user-supplied Proc to fetch the temporary token credential' do
503
502
  temp_cred = Signet::OAuth1::Credential.new(@temporary_credential_key,
504
503
  @temporary_credential_secret)
505
- temp_callback = mock('temp_cred')
506
- temp_callback.should_receive(:call).at_least(:once).with(
504
+ temp_callback = double('temp_cred')
505
+ expect(temp_callback).to receive(:call).at_least(:once).with(
507
506
  @temporary_credential_key
508
507
  ).and_return(temp_cred)
509
508
 
@@ -514,9 +513,9 @@ describe Signet::OAuth1::Server, 'configured' do
514
513
  end
515
514
  it 'should return nil from #request_realm if no realm is provided' do
516
515
  req = make_token_credential_request(@client)
517
- @server.request_realm(
516
+ expect(@server.request_realm(
518
517
  :request=>req
519
- ).should == nil
518
+ )).to eq nil
520
519
  end
521
520
 
522
521
  describe 'with a Realm provided' do
@@ -526,15 +525,15 @@ describe Signet::OAuth1::Server, 'configured' do
526
525
  end
527
526
  it 'should return the realm from #request_realm' do
528
527
  req = make_token_credential_request(@client, nil, @realm)
529
- @server.request_realm(
528
+ expect(@server.request_realm(
530
529
  :request=>req
531
- ).should == @realm
530
+ )).to eq @realm
532
531
  end
533
532
  it 'should an informational hash with a valid request' do
534
533
  req = make_token_credential_request(@client, nil, @realm)
535
- @server.authenticate_token_credential_request(
534
+ expect(@server.authenticate_token_credential_request(
536
535
  :request=>req
537
- ).should == @return_hash
536
+ )).to eq @return_hash
538
537
  end
539
538
  end
540
539
 
@@ -562,7 +561,7 @@ describe Signet::OAuth1::Server, 'configured' do
562
561
  :body => ['A chunked body.'],
563
562
  :headers => make_oauth_signature_header
564
563
  )
565
- approved.should == nil
564
+ expect(approved).to eq nil
566
565
  end
567
566
 
568
567
  it 'should not raise an error if a request body is chunked(as StringIO)' do
@@ -575,18 +574,18 @@ describe Signet::OAuth1::Server, 'configured' do
575
574
  :body => chunked_body,
576
575
  :headers => make_oauth_signature_header
577
576
  )
578
- approved.should == nil
577
+ expect(approved).to eq nil
579
578
  end
580
579
 
581
580
  it 'should raise an error if a request body is of a bogus type' do
582
- (lambda do
581
+ expect(lambda do
583
582
  @server.authenticate_resource_request(
584
583
  :method => 'POST',
585
584
  :uri => 'https://photos.example.net/photos',
586
585
  :body => 42,
587
586
  :headers => make_oauth_signature_header
588
587
  )
589
- end).should raise_error(TypeError)
588
+ end).to raise_error(TypeError)
590
589
  end
591
590
  it 'should use form parameters in signature if request is a POSTed form' do
592
591
  req = make_resource_request(
@@ -594,7 +593,7 @@ describe Signet::OAuth1::Server, 'configured' do
594
593
  {:method=>'POST',
595
594
  :headers=>{'Content-Type'=>'application/x-www-form-urlencoded'},
596
595
  :body=>'c2&a3=2+q'})
597
- @server.authenticate_resource_request(:request=>req).should == @return_hash
596
+ expect(@server.authenticate_resource_request(:request=>req)).to eq @return_hash
598
597
  end
599
598
  it 'should raise an error if signature is x-www-form-encoded ' +
600
599
  'but does not send form parameters in header' do
@@ -609,17 +608,17 @@ describe Signet::OAuth1::Server, 'configured' do
609
608
 
610
609
  req.headers["Authorization"].gsub!(/c2=\"\", a3=\"2%20q\", /, '')
611
610
 
612
- (lambda do
611
+ expect(lambda do
613
612
  @server.authenticate_resource_request(:request=>req)
614
- end).should raise_error(Signet::MalformedAuthorizationError,
613
+ end).to raise_error(Signet::MalformedAuthorizationError,
615
614
  'Request is of type application/x-www-form-urlencoded but ' +
616
615
  'Authentication header did not include form values'
617
616
  )
618
617
  end
619
618
 
620
619
  it 'should call a user-supplied Proc to validate a nonce/timestamp pair' do
621
- nonce_callback = mock('nonce')
622
- nonce_callback.should_receive(:call).once.with(
620
+ nonce_callback = double('nonce')
621
+ expect(nonce_callback).to receive(:call).once.with(
623
622
  an_instance_of(String), an_instance_of(String)
624
623
  ).and_return(true)
625
624
 
@@ -632,8 +631,8 @@ describe Signet::OAuth1::Server, 'configured' do
632
631
  it 'should call a user-supplied Proc to fetch the client credential' do
633
632
  client_cred = Signet::OAuth1::Credential.new(@client_credential_key,
634
633
  @client_credential_secret )
635
- key_callback = mock('client_cred' )
636
- key_callback.should_receive(:call).at_least(:once).with(
634
+ key_callback = double('client_cred' )
635
+ expect(key_callback).to receive(:call).at_least(:once).with(
637
636
  @client_credential_key
638
637
  ).and_return(client_cred)
639
638
 
@@ -646,8 +645,8 @@ describe Signet::OAuth1::Server, 'configured' do
646
645
  it 'should call a user-supplied Proc to fetch the token credential' do
647
646
  token_cred = Signet::OAuth1::Credential.new(@token_credential_key,
648
647
  @token_credential_secret)
649
- key_callback = mock('token_cred' )
650
- key_callback.should_receive(:call).at_least(:once).with(
648
+ key_callback = double('token_cred' )
649
+ expect(key_callback).to receive(:call).at_least(:once).with(
651
650
  @token_credential_key
652
651
  ).and_return(token_cred)
653
652
 
@@ -658,21 +657,21 @@ describe Signet::OAuth1::Server, 'configured' do
658
657
  end
659
658
 
660
659
  it 'should return a Hash for a valid request' do
661
- @server.authenticate_resource_request(
660
+ expect(@server.authenticate_resource_request(
662
661
  :request=>make_resource_request(@client)
663
- ).should == @return_hash
662
+ )).to eq @return_hash
664
663
  end
665
664
  it 'should return nil for a unauthenticated request' do
666
665
  bad_request = make_resource_request(@client)
667
666
  bad_request.headers["Authorization"].gsub!(/oauth_signature=\".+\"/,
668
667
  "oauth_signature=\"foobar\"")
669
- @server.authenticate_resource_request(:request=>bad_request).should == nil
668
+ expect(@server.authenticate_resource_request(:request=>bad_request)).to eq nil
670
669
  end
671
670
  it 'should return nil from #request_realm if no realm is provided' do
672
671
  req = make_resource_request(@client)
673
- @server.request_realm(
672
+ expect(@server.request_realm(
674
673
  :request=>req
675
- ).should == nil
674
+ )).to eq nil
676
675
  end
677
676
 
678
677
  describe 'with a Realm provided' do
@@ -682,15 +681,15 @@ describe Signet::OAuth1::Server, 'configured' do
682
681
  end
683
682
  it 'should return the realm from #request_realm' do
684
683
  req = make_resource_request(@client, {}, @realm)
685
- @server.request_realm(
684
+ expect(@server.request_realm(
686
685
  :request=>req
687
- ).should == @realm
686
+ )).to eq @realm
688
687
  end
689
688
  it 'should return a hash containing the realm with a valid request' do
690
689
  req = make_resource_request(@client, {}, @realm)
691
- @server.authenticate_resource_request(
690
+ expect(@server.authenticate_resource_request(
692
691
  :request=>req
693
- ).should == @return_hash
692
+ )).to eq @return_hash
694
693
  end
695
694
  end
696
695
 
@@ -717,7 +716,7 @@ describe Signet::OAuth1::Server, 'configured' do
717
716
  :headers => make_oauth_signature_header,
718
717
  :two_legged=>true
719
718
  )
720
- approved.should == nil
719
+ expect(approved).to eq nil
721
720
  end
722
721
 
723
722
  it 'should not raise an error if a request body is chunked(as StringIO)' do
@@ -731,11 +730,11 @@ describe Signet::OAuth1::Server, 'configured' do
731
730
  :headers => make_oauth_signature_header,
732
731
  :two_legged=>true
733
732
  )
734
- approved.should == nil
733
+ expect(approved).to eq nil
735
734
  end
736
735
 
737
736
  it 'should raise an error if a request body is of a bogus type' do
738
- (lambda do
737
+ expect(lambda do
739
738
  @server.authenticate_resource_request(
740
739
  :method => 'POST',
741
740
  :uri => 'https://photos.example.net/photos',
@@ -743,7 +742,7 @@ describe Signet::OAuth1::Server, 'configured' do
743
742
  :headers => make_oauth_signature_header,
744
743
  :two_legged=>true
745
744
  )
746
- end).should raise_error(TypeError)
745
+ end).to raise_error(TypeError)
747
746
  end
748
747
  it 'should use form parameters in signature if request is a POSTed form' do
749
748
  req = make_resource_request(
@@ -752,9 +751,9 @@ describe Signet::OAuth1::Server, 'configured' do
752
751
  :headers=>{'Content-Type'=>'application/x-www-form-urlencoded'},
753
752
  :body=>'c2&a3=2+q'}
754
753
  )
755
- @server.authenticate_resource_request(
754
+ expect(@server.authenticate_resource_request(
756
755
  :request=>req, :two_legged=>true
757
- ).should == @return_hash
756
+ )).to eq @return_hash
758
757
  end
759
758
  it 'should raise an error if signature is x-www-form-encoded '+
760
759
  'but does not send form parameters in header' do
@@ -770,17 +769,17 @@ describe Signet::OAuth1::Server, 'configured' do
770
769
 
771
770
  req.headers["Authorization"].gsub!(/c2=\"\", a3=\"2%20q\", /, '')
772
771
 
773
- (lambda do
772
+ expect(lambda do
774
773
  @server.authenticate_resource_request(:request=>req, :two_legged=>true)
775
- end).should raise_error(Signet::MalformedAuthorizationError,
774
+ end).to raise_error(Signet::MalformedAuthorizationError,
776
775
  'Request is of type application/x-www-form-urlencoded but '+
777
776
  'Authentication header did not include form values'
778
777
  )
779
778
  end
780
779
 
781
780
  it 'should call a user-supplied Proc to validate a nonce/timestamp pair' do
782
- nonce_callback = mock('nonce')
783
- nonce_callback.should_receive(:call).once.with(
781
+ nonce_callback = double('nonce')
782
+ expect(nonce_callback).to receive(:call).once.with(
784
783
  an_instance_of(String), an_instance_of(String)
785
784
  ).and_return(true)
786
785
 
@@ -793,8 +792,8 @@ describe Signet::OAuth1::Server, 'configured' do
793
792
  it 'should call a user-supplied Proc to fetch the client credential' do
794
793
  client_cred = Signet::OAuth1::Credential.new(@client_credential_key,
795
794
  @client_credential_secret )
796
- key_callback = mock('client_cred')
797
- key_callback.should_receive(:call).at_least(:once).with(
795
+ key_callback = double('client_cred')
796
+ expect(key_callback).to receive(:call).at_least(:once).with(
798
797
  @client_credential_key
799
798
  ).and_return(client_cred)
800
799
 
@@ -805,21 +804,21 @@ describe Signet::OAuth1::Server, 'configured' do
805
804
  end
806
805
 
807
806
  it 'should return a informational hash for a valid request' do
808
- @server.authenticate_resource_request(
807
+ expect(@server.authenticate_resource_request(
809
808
  :request=>make_resource_request(@client), :two_legged=>true
810
- ).should == @return_hash
809
+ )).to eq @return_hash
811
810
  end
812
811
  it 'should return false for a unauthenticated request' do
813
812
  bad_request = make_resource_request(@client)
814
813
  bad_request.headers["Authorization"].gsub!(/oauth_signature=\".+\"/,
815
814
  "oauth_signature=\"foobar\"")
816
- @server.authenticate_resource_request(:request=>bad_request).should == nil
815
+ expect(@server.authenticate_resource_request(:request=>bad_request)).to eq nil
817
816
  end
818
817
  it 'should return nil from #request_realm if no realm is provided' do
819
818
  req = make_resource_request(@client)
820
- @server.request_realm(
819
+ expect(@server.request_realm(
821
820
  :request=>req
822
- ).should == nil
821
+ )).to eq nil
823
822
  end
824
823
  describe 'with a Realm provided' do
825
824
  before do
@@ -828,16 +827,16 @@ describe Signet::OAuth1::Server, 'configured' do
828
827
  end
829
828
  it 'should return the realm from #request_realm' do
830
829
  req = make_resource_request(@client, {}, @realm)
831
- @server.request_realm(
830
+ expect(@server.request_realm(
832
831
  :request=>req, :two_legged=>true
833
- ).should == @realm
832
+ )).to eq @realm
834
833
  end
835
834
 
836
835
  it 'should return a hash containing the realm with a valid request' do
837
836
  req = make_resource_request(@client, {}, @realm)
838
- @server.authenticate_resource_request(
837
+ expect(@server.authenticate_resource_request(
839
838
  :request=>req, :two_legged=>true
840
- ).should == @return_hash
839
+ )).to eq @return_hash
841
840
  end
842
841
  end
843
842