sinatra-contrib 1.4.7 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,8 +9,8 @@ describe Sinatra::Cookies do
9
9
  "ok"
10
10
  end
11
11
  get '/', {}, @headers || {}
12
- last_response.should be_ok
13
- body.should be == "ok"
12
+ expect(last_response).to be_ok
13
+ expect(body).to eq("ok")
14
14
  result
15
15
  end
16
16
 
@@ -32,110 +32,110 @@ describe Sinatra::Cookies do
32
32
  it 'runs the block' do
33
33
  ran = false
34
34
  cookie_route { ran = true }
35
- ran.should be true
35
+ expect(ran).to be true
36
36
  end
37
37
 
38
38
  it 'returns the block result' do
39
- cookie_route { 42 }.should be == 42
39
+ expect(cookie_route { 42 }).to eq(42)
40
40
  end
41
41
  end
42
42
 
43
43
  describe :== do
44
44
  it 'is comparable to hashes' do
45
- cookies.should be == {}
45
+ expect(cookies).to eq({})
46
46
  end
47
47
 
48
48
  it 'is comparable to anything that responds to to_hash' do
49
49
  other = Struct.new(:to_hash).new({})
50
- cookies.should be == other
50
+ expect(cookies).to eq(other)
51
51
  end
52
52
  end
53
53
 
54
54
  describe :[] do
55
55
  it 'allows access to request cookies' do
56
- cookies("foo=bar")["foo"].should be == "bar"
56
+ expect(cookies("foo=bar")["foo"]).to eq("bar")
57
57
  end
58
58
 
59
59
  it 'takes symbols as keys' do
60
- cookies("foo=bar")[:foo].should be == "bar"
60
+ expect(cookies("foo=bar")[:foo]).to eq("bar")
61
61
  end
62
62
 
63
63
  it 'returns nil for missing keys' do
64
- cookies("foo=bar")['bar'].should be_nil
64
+ expect(cookies("foo=bar")['bar']).to be_nil
65
65
  end
66
66
 
67
67
  it 'allows access to response cookies' do
68
- cookie_route do
68
+ expect(cookie_route do
69
69
  response.set_cookie 'foo', 'bar'
70
70
  cookies['foo']
71
- end.should be == 'bar'
71
+ end).to eq('bar')
72
72
  end
73
73
 
74
74
  it 'favors response cookies over request cookies' do
75
- cookie_route('foo=bar') do
75
+ expect(cookie_route('foo=bar') do
76
76
  response.set_cookie 'foo', 'baz'
77
77
  cookies['foo']
78
- end.should be == 'baz'
78
+ end).to eq('baz')
79
79
  end
80
80
 
81
81
 
82
82
  it 'takes the last value for response cookies' do
83
- cookie_route do
83
+ expect(cookie_route do
84
84
  response.set_cookie 'foo', 'bar'
85
85
  response.set_cookie 'foo', 'baz'
86
86
  cookies['foo']
87
- end.should be == 'baz'
87
+ end).to eq('baz')
88
88
  end
89
89
  end
90
90
 
91
91
  describe :[]= do
92
92
  it 'sets cookies to httponly' do
93
- cookie_route do
93
+ expect(cookie_route do
94
94
  cookies['foo'] = 'bar'
95
95
  response['Set-Cookie'].lines.detect { |l| l.start_with? 'foo=' }
96
- end.should include('HttpOnly')
96
+ end).to include('HttpOnly')
97
97
  end
98
98
 
99
99
  it 'sets domain to nil if localhost' do
100
100
  @headers = {'HTTP_HOST' => 'localhost'}
101
- cookie_route do
101
+ expect(cookie_route do
102
102
  cookies['foo'] = 'bar'
103
103
  response['Set-Cookie']
104
- end.should_not include("domain")
104
+ end).not_to include("domain")
105
105
  end
106
106
 
107
107
  it 'sets the domain' do
108
- cookie_route do
108
+ expect(cookie_route do
109
109
  cookies['foo'] = 'bar'
110
110
  response['Set-Cookie'].lines.detect { |l| l.start_with? 'foo=' }
111
- end.should include('domain=example.org')
111
+ end).to include('domain=example.org')
112
112
  end
113
113
 
114
114
  it 'sets path to / by default' do
115
- cookie_route do
115
+ expect(cookie_route do
116
116
  cookies['foo'] = 'bar'
117
117
  response['Set-Cookie'].lines.detect { |l| l.start_with? 'foo=' }
118
- end.should include('path=/')
118
+ end).to include('path=/')
119
119
  end
120
120
 
121
121
  it 'sets path to the script_name if app is nested' do
122
- cookie_route do
122
+ expect(cookie_route do
123
123
  request.script_name = '/foo'
124
124
  cookies['foo'] = 'bar'
125
125
  response['Set-Cookie'].lines.detect { |l| l.start_with? 'foo=' }
126
- end.should include('path=/foo')
126
+ end).to include('path=/foo')
127
127
  end
128
128
 
129
129
  it 'sets a cookie' do
130
130
  cookie_route { cookies['foo'] = 'bar' }
131
- cookie_jar['foo'].should be == 'bar'
131
+ expect(cookie_jar['foo']).to eq('bar')
132
132
  end
133
133
 
134
134
  it 'adds a value to the cookies hash' do
135
- cookie_route do
135
+ expect(cookie_route do
136
136
  cookies['foo'] = 'bar'
137
137
  cookies['foo']
138
- end.should be == 'bar'
138
+ end).to eq('bar')
139
139
  end
140
140
  end
141
141
 
@@ -148,60 +148,60 @@ describe Sinatra::Cookies do
148
148
  describe :clear do
149
149
  it 'removes request cookies from cookies hash' do
150
150
  jar = cookies('foo=bar')
151
- jar['foo'].should be == 'bar'
151
+ expect(jar['foo']).to eq('bar')
152
152
  jar.clear
153
- jar['foo'].should be_nil
153
+ expect(jar['foo']).to be_nil
154
154
  end
155
155
 
156
156
  it 'removes response cookies from cookies hash' do
157
- cookie_route do
157
+ expect(cookie_route do
158
158
  cookies['foo'] = 'bar'
159
159
  cookies.clear
160
160
  cookies['foo']
161
- end.should be_nil
161
+ end).to be_nil
162
162
  end
163
163
 
164
164
  it 'expires existing cookies' do
165
- cookie_route("foo=bar") do
165
+ expect(cookie_route("foo=bar") do
166
166
  cookies.clear
167
167
  response['Set-Cookie']
168
- end.should include("foo=;", "expires=", "1970 00:00:00")
168
+ end).to include("foo=;", "expires=", "1970 00:00:00")
169
169
  end
170
170
  end
171
171
 
172
172
  describe :compare_by_identity? do
173
- it { cookies.should_not be_compare_by_identity }
173
+ it { expect(cookies).not_to be_compare_by_identity }
174
174
  end
175
175
 
176
176
  describe :default do
177
- it { cookies.default.should be_nil }
177
+ it { expect(cookies.default).to be_nil }
178
178
  end
179
179
 
180
180
  describe :default_proc do
181
- it { cookies.default_proc.should be_nil }
181
+ it { expect(cookies.default_proc).to be_nil }
182
182
  end
183
183
 
184
184
  describe :delete do
185
185
  it 'removes request cookies from cookies hash' do
186
186
  jar = cookies('foo=bar')
187
- jar['foo'].should be == 'bar'
187
+ expect(jar['foo']).to eq('bar')
188
188
  jar.delete 'foo'
189
- jar['foo'].should be_nil
189
+ expect(jar['foo']).to be_nil
190
190
  end
191
191
 
192
192
  it 'removes response cookies from cookies hash' do
193
- cookie_route do
193
+ expect(cookie_route do
194
194
  cookies['foo'] = 'bar'
195
195
  cookies.delete 'foo'
196
196
  cookies['foo']
197
- end.should be_nil
197
+ end).to be_nil
198
198
  end
199
199
 
200
200
  it 'expires existing cookies' do
201
- cookie_route("foo=bar") do
201
+ expect(cookie_route("foo=bar") do
202
202
  cookies.delete 'foo'
203
203
  response['Set-Cookie']
204
- end.should include("foo=;", "expires=", "1970 00:00:00")
204
+ end).to include("foo=;", "expires=", "1970 00:00:00")
205
205
  end
206
206
 
207
207
  it 'honours the app cookie_options' do
@@ -217,42 +217,42 @@ describe Sinatra::Cookies do
217
217
  cookies.delete 'foo'
218
218
  response['Set-Cookie']
219
219
  end
220
- cookie_header.should include("path=/foo;", "domain=bar.com;", "secure;", "HttpOnly")
220
+ expect(cookie_header).to include("path=/foo;", "domain=bar.com;", "secure;", "HttpOnly")
221
221
  end
222
222
 
223
223
  it 'does not touch other cookies' do
224
- cookie_route("foo=bar", "bar=baz") do
224
+ expect(cookie_route("foo=bar", "bar=baz") do
225
225
  cookies.delete 'foo'
226
226
  cookies['bar']
227
- end.should be == 'baz'
227
+ end).to eq('baz')
228
228
  end
229
229
 
230
230
  it 'returns the previous value for request cookies' do
231
- cookie_route("foo=bar") do
231
+ expect(cookie_route("foo=bar") do
232
232
  cookies.delete "foo"
233
- end.should be == "bar"
233
+ end).to eq("bar")
234
234
  end
235
235
 
236
236
  it 'returns the previous value for response cookies' do
237
- cookie_route do
237
+ expect(cookie_route do
238
238
  cookies['foo'] = 'bar'
239
239
  cookies.delete "foo"
240
- end.should be == "bar"
240
+ end).to eq("bar")
241
241
  end
242
242
 
243
243
  it 'returns nil for non-existing cookies' do
244
- cookie_route { cookies.delete("foo") }.should be_nil
244
+ expect(cookie_route { cookies.delete("foo") }).to be_nil
245
245
  end
246
246
  end
247
247
 
248
248
  describe :delete_if do
249
249
  it 'deletes cookies that match the block' do
250
- cookie_route('foo=bar') do
250
+ expect(cookie_route('foo=bar') do
251
251
  cookies['bar'] = 'baz'
252
252
  cookies['baz'] = 'foo'
253
253
  cookies.delete_if { |*a| a.include? 'bar' }
254
254
  cookies.values_at 'foo', 'bar', 'baz'
255
- end.should be == [nil, nil, 'foo']
255
+ end).to eq([nil, nil, 'foo'])
256
256
  end
257
257
  end
258
258
 
@@ -270,22 +270,25 @@ describe Sinatra::Cookies do
270
270
  end
271
271
  end
272
272
 
273
- keys.sort.should be == ['bar', 'foo']
274
- foo.should be == 'bar'
275
- bar.should be == 'baz'
273
+ expect(keys.sort).to eq(['bar', 'foo'])
274
+ expect(foo).to eq('bar')
275
+ expect(bar).to eq('baz')
276
276
  end
277
277
 
278
278
  it 'favors response over request cookies' do
279
279
  seen = false
280
+ key = nil
281
+ value = nil
280
282
  cookie_route('foo=bar') do
281
283
  cookies[:foo] = 'baz'
282
- cookies.each do |key, value|
283
- key.should == 'foo'
284
- value.should == 'baz'
285
- seen.should == false
286
- seen = true
284
+ cookies.each do |k,v|
285
+ key = k
286
+ value = v
287
287
  end
288
288
  end
289
+ expect(key).to eq('foo')
290
+ expect(value).to eq('baz')
291
+ expect(seen).to eq(false)
289
292
  end
290
293
 
291
294
  it 'does not loop through deleted cookies' do
@@ -296,10 +299,12 @@ describe Sinatra::Cookies do
296
299
  end
297
300
 
298
301
  it 'returns an enumerator' do
302
+ keys = []
299
303
  cookie_route('foo=bar') do
300
304
  enum = cookies.each
301
- enum.each { |key, value| key.should == 'foo' }
305
+ enum.each { |key, value| keys << key }
302
306
  end
307
+ keys.each{ |key| expect(key).to eq('foo')}
303
308
  end
304
309
  end
305
310
 
@@ -313,18 +318,15 @@ describe Sinatra::Cookies do
313
318
  end
314
319
  end
315
320
 
316
- keys.sort.should be == ['bar', 'foo']
321
+ expect(keys.sort).to eq(['bar', 'foo'])
317
322
  end
318
323
 
319
324
  it 'only yields keys once' do
320
325
  seen = false
321
326
  cookie_route('foo=bar') do
322
327
  cookies[:foo] = 'baz'
323
- cookies.each_key do |key|
324
- seen.should == false
325
- seen = true
326
- end
327
328
  end
329
+ expect(seen).to eq(false)
328
330
  end
329
331
 
330
332
  it 'does not loop through deleted cookies' do
@@ -335,10 +337,12 @@ describe Sinatra::Cookies do
335
337
  end
336
338
 
337
339
  it 'returns an enumerator' do
340
+ keys = []
338
341
  cookie_route('foo=bar') do
339
342
  enum = cookies.each_key
340
- enum.each { |key| key.should == 'foo' }
343
+ enum.each { |key| keys << key }
341
344
  end
345
+ keys.each{ |key| expect(key).to eq('foo')}
342
346
  end
343
347
  end
344
348
 
@@ -356,22 +360,25 @@ describe Sinatra::Cookies do
356
360
  end
357
361
  end
358
362
 
359
- keys.sort.should be == ['bar', 'foo']
360
- foo.should be == 'bar'
361
- bar.should be == 'baz'
363
+ expect(keys.sort).to eq(['bar', 'foo'])
364
+ expect(foo).to eq('bar')
365
+ expect(bar).to eq('baz')
362
366
  end
363
367
 
364
368
  it 'favors response over request cookies' do
365
369
  seen = false
370
+ key = nil
371
+ value = nil
366
372
  cookie_route('foo=bar') do
367
373
  cookies[:foo] = 'baz'
368
- cookies.each_pair do |key, value|
369
- key.should == 'foo'
370
- value.should == 'baz'
371
- seen.should == false
372
- seen = true
374
+ cookies.each_pair do |k, v|
375
+ key = k
376
+ value = v
373
377
  end
374
378
  end
379
+ expect(key).to eq('foo')
380
+ expect(value).to eq('baz')
381
+ expect(seen).to eq(false)
375
382
  end
376
383
 
377
384
  it 'does not loop through deleted cookies' do
@@ -382,10 +389,12 @@ describe Sinatra::Cookies do
382
389
  end
383
390
 
384
391
  it 'returns an enumerator' do
392
+ keys = []
385
393
  cookie_route('foo=bar') do
386
394
  enum = cookies.each_pair
387
- enum.each { |key, value| key.should == 'foo' }
395
+ enum.each { |key, value| keys << key }
388
396
  end
397
+ keys.each{ |key| expect(key).to eq('foo')}
389
398
  end
390
399
  end
391
400
 
@@ -399,19 +408,19 @@ describe Sinatra::Cookies do
399
408
  end
400
409
  end
401
410
 
402
- values.sort.should be == ['bar', 'baz']
411
+ expect(values.sort).to eq(['bar', 'baz'])
403
412
  end
404
413
 
405
414
  it 'favors response over request cookies' do
406
415
  seen = false
416
+ value = nil
407
417
  cookie_route('foo=bar') do
408
418
  cookies[:foo] = 'baz'
409
- cookies.each_value do |value|
410
- value.should == 'baz'
411
- seen.should == false
412
- seen = true
419
+ cookies.each_value do |v|
420
+ value = v
413
421
  end
414
422
  end
423
+ expect(value).to eq('baz')
415
424
  end
416
425
 
417
426
  it 'does not loop through deleted cookies' do
@@ -422,249 +431,234 @@ describe Sinatra::Cookies do
422
431
  end
423
432
 
424
433
  it 'returns an enumerator' do
434
+ enum = nil
425
435
  cookie_route('foo=bar') do
426
436
  enum = cookies.each_value
427
- enum.each { |value| value.should == 'bar' }
428
437
  end
438
+ enum.each { |value| expect(value).to eq('bar') }
429
439
  end
430
440
  end
431
441
 
432
442
  describe :empty? do
433
443
  it 'returns true if there are no cookies' do
434
- cookies.should be_empty
444
+ expect(cookies).to be_empty
435
445
  end
436
446
 
437
447
  it 'returns false if there are request cookies' do
438
- cookies('foo=bar').should_not be_empty
448
+ expect(cookies('foo=bar')).not_to be_empty
439
449
  end
440
450
 
441
451
  it 'returns false if there are response cookies' do
442
- cookie_route do
452
+ expect(cookie_route do
443
453
  cookies['foo'] = 'bar'
444
454
  cookies.empty?
445
- end.should be false
455
+ end).to be false
446
456
  end
447
457
 
448
458
  it 'becomes true if response cookies are removed' do
449
- cookie_route do
459
+ expect(cookie_route do
450
460
  cookies['foo'] = 'bar'
451
461
  cookies.delete :foo
452
462
  cookies.empty?
453
- end.should be true
463
+ end).to be true
454
464
  end
455
465
 
456
466
  it 'becomes true if request cookies are removed' do
457
- cookie_route('foo=bar') do
467
+ expect(cookie_route('foo=bar') do
458
468
  cookies.delete :foo
459
469
  cookies.empty?
460
- end.should be_truthy
470
+ end).to be_truthy
461
471
  end
462
472
 
463
473
  it 'becomes true after clear' do
464
- cookie_route('foo=bar', 'bar=baz') do
474
+ expect(cookie_route('foo=bar', 'bar=baz') do
465
475
  cookies['foo'] = 'bar'
466
476
  cookies.clear
467
477
  cookies.empty?
468
- end.should be_truthy
478
+ end).to be_truthy
469
479
  end
470
480
  end
471
481
 
472
482
  describe :fetch do
473
483
  it 'returns values from request cookies' do
474
- cookies('foo=bar').fetch('foo').should be == 'bar'
484
+ expect(cookies('foo=bar').fetch('foo')).to eq('bar')
475
485
  end
476
486
 
477
487
  it 'returns values from response cookies' do
478
- cookie_route do
488
+ expect(cookie_route do
479
489
  cookies['foo'] = 'bar'
480
490
  cookies.fetch('foo')
481
- end.should be == 'bar'
491
+ end).to eq('bar')
482
492
  end
483
493
 
484
494
  it 'favors response over request cookies' do
485
- cookie_route('foo=baz') do
495
+ expect(cookie_route('foo=baz') do
486
496
  cookies['foo'] = 'bar'
487
497
  cookies.fetch('foo')
488
- end.should be == 'bar'
498
+ end).to eq('bar')
489
499
  end
490
500
 
491
501
  it 'raises an exception if key does not exist' do
492
502
  error = if defined? JRUBY_VERSION
493
503
  IndexError
494
504
  else
495
- RUBY_VERSION >= '1.9' ? KeyError : IndexError
505
+ KeyError
496
506
  end
497
507
  expect { cookies.fetch('foo') }.to raise_exception(error)
498
508
  end
499
509
 
500
510
  it 'returns the block result if missing' do
501
- cookies.fetch('foo') { 'bar' }.should be == 'bar'
511
+ expect(cookies.fetch('foo') { 'bar' }).to eq('bar')
502
512
  end
503
513
  end
504
514
 
505
515
  describe :flatten do
506
- it { cookies('foo=bar').flatten.should be == {'foo' => 'bar'}.flatten }
516
+ it { expect(cookies('foo=bar').flatten).to eq({'foo' => 'bar'}.flatten) }
507
517
  end if Hash.method_defined? :flatten
508
518
 
509
519
  describe :has_key? do
510
520
  it 'checks request cookies' do
511
- cookies('foo=bar').should have_key('foo')
521
+ expect(cookies('foo=bar')).to have_key('foo')
512
522
  end
513
523
 
514
524
  it 'checks response cookies' do
515
525
  jar = cookies
516
526
  jar['foo'] = 'bar'
517
- jar.should have_key(:foo)
527
+ expect(jar).to have_key(:foo)
518
528
  end
519
529
 
520
530
  it 'does not use deleted cookies' do
521
531
  jar = cookies('foo=bar')
522
532
  jar.delete :foo
523
- jar.should_not have_key('foo')
533
+ expect(jar).not_to have_key('foo')
524
534
  end
525
535
  end
526
536
 
527
537
  describe :has_value? do
528
538
  it 'checks request cookies' do
529
- cookies('foo=bar').should have_value('bar')
539
+ expect(cookies('foo=bar')).to have_value('bar')
530
540
  end
531
541
 
532
542
  it 'checks response cookies' do
533
543
  jar = cookies
534
544
  jar[:foo] = 'bar'
535
- jar.should have_value('bar')
545
+ expect(jar).to have_value('bar')
536
546
  end
537
547
 
538
548
  it 'does not use deleted cookies' do
539
549
  jar = cookies('foo=bar')
540
550
  jar.delete :foo
541
- jar.should_not have_value('bar')
551
+ expect(jar).not_to have_value('bar')
542
552
  end
543
553
  end
544
554
 
545
555
  describe :include? do
546
556
  it 'checks request cookies' do
547
- cookies('foo=bar').should include('foo')
557
+ expect(cookies('foo=bar')).to include('foo')
548
558
  end
549
559
 
550
560
  it 'checks response cookies' do
551
561
  jar = cookies
552
562
  jar['foo'] = 'bar'
553
- jar.should include(:foo)
563
+ expect(jar).to include(:foo)
554
564
  end
555
565
 
556
566
  it 'does not use deleted cookies' do
557
567
  jar = cookies('foo=bar')
558
568
  jar.delete :foo
559
- jar.should_not include('foo')
569
+ expect(jar).not_to include('foo')
560
570
  end
561
571
  end
562
572
 
563
- describe :index do
564
- it 'checks request cookies' do
565
- cookies('foo=bar').index('bar').should be == 'foo'
566
- end
567
-
568
- it 'checks response cookies' do
569
- jar = cookies
570
- jar['foo'] = 'bar'
571
- jar.index('bar').should be == 'foo'
572
- end
573
-
574
- it 'returns nil when missing' do
575
- cookies('foo=bar').index('baz').should be_nil
576
- end
577
- end if RUBY_VERSION < '1.9'
578
-
579
573
  describe :keep_if do
580
574
  it 'removes entries' do
581
575
  jar = cookies('foo=bar', 'bar=baz')
582
576
  jar.keep_if { |*args| args == ['bar', 'baz'] }
583
- jar.should be == {'bar' => 'baz'}
577
+ expect(jar).to eq({'bar' => 'baz'})
584
578
  end
585
579
  end
586
580
 
587
581
  describe :key do
588
582
  it 'checks request cookies' do
589
- cookies('foo=bar').key('bar').should be == 'foo'
583
+ expect(cookies('foo=bar').key('bar')).to eq('foo')
590
584
  end
591
585
 
592
586
  it 'checks response cookies' do
593
587
  jar = cookies
594
588
  jar['foo'] = 'bar'
595
- jar.key('bar').should be == 'foo'
589
+ expect(jar.key('bar')).to eq('foo')
596
590
  end
597
591
 
598
592
  it 'returns nil when missing' do
599
- cookies('foo=bar').key('baz').should be_nil
593
+ expect(cookies('foo=bar').key('baz')).to be_nil
600
594
  end
601
595
  end
602
596
 
603
597
  describe :key? do
604
598
  it 'checks request cookies' do
605
- cookies('foo=bar').key?('foo').should be true
599
+ expect(cookies('foo=bar').key?('foo')).to be true
606
600
  end
607
601
 
608
602
  it 'checks response cookies' do
609
603
  jar = cookies
610
604
  jar['foo'] = 'bar'
611
- jar.key?(:foo).should be true
605
+ expect(jar.key?(:foo)).to be true
612
606
  end
613
607
 
614
608
  it 'does not use deleted cookies' do
615
609
  jar = cookies('foo=bar')
616
610
  jar.delete :foo
617
- jar.key?('foo').should be false
611
+ expect(jar.key?('foo')).to be false
618
612
  end
619
613
  end
620
614
 
621
615
  describe :keys do
622
- it { cookies('foo=bar').keys.should == ['foo'] }
616
+ it { expect(cookies('foo=bar').keys).to eq(['foo']) }
623
617
  end
624
618
 
625
619
  describe :length do
626
- it { cookies.length.should == 0 }
627
- it { cookies('foo=bar').length.should == 1 }
620
+ it { expect(cookies.length).to eq(0) }
621
+ it { expect(cookies('foo=bar').length).to eq(1) }
628
622
  end
629
623
 
630
624
  describe :member? do
631
625
  it 'checks request cookies' do
632
- cookies('foo=bar').member?('foo').should be true
626
+ expect(cookies('foo=bar').member?('foo')).to be true
633
627
  end
634
628
 
635
629
  it 'checks response cookies' do
636
630
  jar = cookies
637
631
  jar['foo'] = 'bar'
638
- jar.member?(:foo).should be true
632
+ expect(jar.member?(:foo)).to be true
639
633
  end
640
634
 
641
635
  it 'does not use deleted cookies' do
642
636
  jar = cookies('foo=bar')
643
637
  jar.delete :foo
644
- jar.member?('foo').should be false
638
+ expect(jar.member?('foo')).to be false
645
639
  end
646
640
  end
647
641
 
648
642
  describe :merge do
649
643
  it 'is mergable with a hash' do
650
- cookies('foo=bar').merge(:bar => :baz).should be == {"foo" => "bar", :bar => :baz}
644
+ expect(cookies('foo=bar').merge(:bar => :baz)).to eq({"foo" => "bar", :bar => :baz})
651
645
  end
652
646
 
653
647
  it 'does not create cookies' do
654
648
  jar = cookies('foo=bar')
655
649
  jar.merge(:bar => 'baz')
656
- jar.should_not include(:bar)
650
+ expect(jar).not_to include(:bar)
657
651
  end
658
652
 
659
653
  it 'takes a block for conflict resolution' do
660
654
  update = {'foo' => 'baz', 'bar' => 'baz'}
661
655
  merged = cookies('foo=bar').merge(update) do |key, old, other|
662
- key.should be == 'foo'
663
- old.should be == 'bar'
664
- other.should be == 'baz'
656
+ expect(key).to eq('foo')
657
+ expect(old).to eq('bar')
658
+ expect(other).to eq('baz')
665
659
  'foo'
666
660
  end
667
- merged['foo'].should be == 'foo'
661
+ expect(merged['foo']).to eq('foo')
668
662
  end
669
663
  end
670
664
 
@@ -672,25 +666,25 @@ describe Sinatra::Cookies do
672
666
  it 'creates cookies' do
673
667
  jar = cookies('foo=bar')
674
668
  jar.merge! :bar => 'baz'
675
- jar.should include('bar')
669
+ expect(jar).to include('bar')
676
670
  end
677
671
 
678
672
  it 'overrides existing values' do
679
673
  jar = cookies('foo=bar')
680
674
  jar.merge! :foo => "baz"
681
- jar["foo"].should be == "baz"
675
+ expect(jar["foo"]).to eq("baz")
682
676
  end
683
677
 
684
678
  it 'takes a block for conflict resolution' do
685
679
  update = {'foo' => 'baz', 'bar' => 'baz'}
686
680
  jar = cookies('foo=bar')
687
681
  jar.merge!(update) do |key, old, other|
688
- key.should be == 'foo'
689
- old.should be == 'bar'
690
- other.should be == 'baz'
682
+ expect(key).to eq('foo')
683
+ expect(old).to eq('bar')
684
+ expect(other).to eq('baz')
691
685
  'foo'
692
686
  end
693
- jar['foo'].should be == 'foo'
687
+ expect(jar['foo']).to eq('foo')
694
688
  end
695
689
  end
696
690
 
@@ -704,8 +698,8 @@ describe Sinatra::Cookies do
704
698
  it 'removes entries from new hash' do
705
699
  jar = cookies('foo=bar', 'bar=baz')
706
700
  sub = jar.reject { |*args| args == ['bar', 'baz'] }
707
- sub.should be == {'foo' => 'bar'}
708
- jar['bar'].should be == 'baz'
701
+ expect(sub).to eq({'foo' => 'bar'})
702
+ expect(jar['bar']).to eq('baz')
709
703
  end
710
704
  end
711
705
 
@@ -713,7 +707,7 @@ describe Sinatra::Cookies do
713
707
  it 'removes entries' do
714
708
  jar = cookies('foo=bar', 'bar=baz')
715
709
  jar.reject! { |*args| args == ['bar', 'baz'] }
716
- jar.should be == {'foo' => 'bar'}
710
+ expect(jar).to eq({'foo' => 'bar'})
717
711
  end
718
712
  end
719
713
 
@@ -721,7 +715,7 @@ describe Sinatra::Cookies do
721
715
  it 'replaces entries' do
722
716
  jar = cookies('foo=bar', 'bar=baz')
723
717
  jar.replace 'foo' => 'baz', 'baz' => 'bar'
724
- jar.should be == {'foo' => 'baz', 'baz' => 'bar'}
718
+ expect(jar).to eq({'foo' => 'baz', 'baz' => 'bar'})
725
719
  end
726
720
  end
727
721
 
@@ -729,8 +723,8 @@ describe Sinatra::Cookies do
729
723
  it 'removes entries from new hash' do
730
724
  jar = cookies('foo=bar', 'bar=baz')
731
725
  sub = jar.select { |*args| args != ['bar', 'baz'] }
732
- sub.should be == {'foo' => 'bar'}.select { true }
733
- jar['bar'].should be == 'baz'
726
+ expect(sub).to eq({'foo' => 'bar'}.select { true })
727
+ expect(jar['bar']).to eq('baz')
734
728
  end
735
729
  end
736
730
 
@@ -738,72 +732,72 @@ describe Sinatra::Cookies do
738
732
  it 'removes entries' do
739
733
  jar = cookies('foo=bar', 'bar=baz')
740
734
  jar.select! { |*args| args != ['bar', 'baz'] }
741
- jar.should be == {'foo' => 'bar'}
735
+ expect(jar).to eq({'foo' => 'bar'})
742
736
  end
743
737
  end if Hash.method_defined? :select!
744
738
 
745
739
  describe :shift do
746
740
  it 'removes from the hash' do
747
741
  jar = cookies('foo=bar')
748
- jar.shift.should be == ['foo', 'bar']
749
- jar.should_not include('bar')
742
+ expect(jar.shift).to eq(['foo', 'bar'])
743
+ expect(jar).not_to include('bar')
750
744
  end
751
745
  end
752
746
 
753
747
  describe :size do
754
- it { cookies.size.should == 0 }
755
- it { cookies('foo=bar').size.should == 1 }
748
+ it { expect(cookies.size).to eq(0) }
749
+ it { expect(cookies('foo=bar').size).to eq(1) }
756
750
  end
757
751
 
758
752
  describe :update do
759
753
  it 'creates cookies' do
760
754
  jar = cookies('foo=bar')
761
755
  jar.update :bar => 'baz'
762
- jar.should include('bar')
756
+ expect(jar).to include('bar')
763
757
  end
764
758
 
765
759
  it 'overrides existing values' do
766
760
  jar = cookies('foo=bar')
767
761
  jar.update :foo => "baz"
768
- jar["foo"].should be == "baz"
762
+ expect(jar["foo"]).to eq("baz")
769
763
  end
770
764
 
771
765
  it 'takes a block for conflict resolution' do
772
766
  merge = {'foo' => 'baz', 'bar' => 'baz'}
773
767
  jar = cookies('foo=bar')
774
768
  jar.update(merge) do |key, old, other|
775
- key.should be == 'foo'
776
- old.should be == 'bar'
777
- other.should be == 'baz'
769
+ expect(key).to eq('foo')
770
+ expect(old).to eq('bar')
771
+ expect(other).to eq('baz')
778
772
  'foo'
779
773
  end
780
- jar['foo'].should be == 'foo'
774
+ expect(jar['foo']).to eq('foo')
781
775
  end
782
776
  end
783
777
 
784
778
  describe :value? do
785
779
  it 'checks request cookies' do
786
- cookies('foo=bar').value?('bar').should be true
780
+ expect(cookies('foo=bar').value?('bar')).to be true
787
781
  end
788
782
 
789
783
  it 'checks response cookies' do
790
784
  jar = cookies
791
785
  jar[:foo] = 'bar'
792
- jar.value?('bar').should be true
786
+ expect(jar.value?('bar')).to be true
793
787
  end
794
788
 
795
789
  it 'does not use deleted cookies' do
796
790
  jar = cookies('foo=bar')
797
791
  jar.delete :foo
798
- jar.value?('bar').should be false
792
+ expect(jar.value?('bar')).to be false
799
793
  end
800
794
  end
801
795
 
802
796
  describe :values do
803
- it { cookies('foo=bar', 'bar=baz').values.sort.should be == ['bar', 'baz'] }
797
+ it { expect(cookies('foo=bar', 'bar=baz').values.sort).to eq(['bar', 'baz']) }
804
798
  end
805
799
 
806
800
  describe :values_at do
807
- it { cookies('foo=bar', 'bar=baz').values_at('foo').should be == ['bar'] }
801
+ it { expect(cookies('foo=bar', 'bar=baz').values_at('foo')).to eq(['bar']) }
808
802
  end
809
803
  end