rufus-scheduler 3.0.7 → 3.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/spec/job_spec.rb CHANGED
@@ -38,7 +38,7 @@ describe Rufus::Scheduler::Job do
38
38
 
39
39
  job = @scheduler.schedule_in '10d' do; end
40
40
 
41
- job.last_time.should == nil
41
+ expect(job.last_time).to eq(nil)
42
42
  end
43
43
 
44
44
  it 'returns the last time the job fired' do
@@ -47,7 +47,7 @@ describe Rufus::Scheduler::Job do
47
47
 
48
48
  sleep 0.4
49
49
 
50
- job.last_time.should_not == nil
50
+ expect(job.last_time).not_to eq(nil)
51
51
  end
52
52
  end
53
53
 
@@ -57,7 +57,7 @@ describe Rufus::Scheduler::Job do
57
57
 
58
58
  job = @scheduler.in('1d', :job => true) {}
59
59
 
60
- job.threads.size.should == 0
60
+ expect(job.threads.size).to eq(0)
61
61
  end
62
62
 
63
63
  it 'returns an empty list after the job terminated' do
@@ -66,7 +66,7 @@ describe Rufus::Scheduler::Job do
66
66
 
67
67
  sleep 0.8
68
68
 
69
- job.threads.size.should == 0
69
+ expect(job.threads.size).to eq(0)
70
70
  end
71
71
 
72
72
  it 'lists the threads the job currently runs in' do
@@ -78,10 +78,10 @@ describe Rufus::Scheduler::Job do
78
78
 
79
79
  sleep 0.4
80
80
 
81
- job.threads.size.should == 1
81
+ expect(job.threads.size).to eq(1)
82
82
 
83
83
  t = job.threads.first
84
- t[:rufus_scheduler_job].should == job
84
+ expect(t[:rufus_scheduler_job]).to eq(job)
85
85
  end
86
86
  end
87
87
 
@@ -95,7 +95,7 @@ describe Rufus::Scheduler::Job do
95
95
 
96
96
  job.kill
97
97
 
98
- Thread.list.size.should == tls
98
+ expect(Thread.list.size).to eq(tls)
99
99
  end
100
100
 
101
101
  it 'makes the threads vacant' do
@@ -120,13 +120,13 @@ describe Rufus::Scheduler::Job do
120
120
  v1 = @scheduler.work_threads(:vacant).size
121
121
  a1 = @scheduler.work_threads(:active).size
122
122
 
123
- counter.should == 0
123
+ expect(counter).to eq(0)
124
124
 
125
- v0.should == 0
126
- a0.should == 1
125
+ expect(v0).to eq(0)
126
+ expect(a0).to eq(1)
127
127
 
128
- v1.should == 1
129
- a1.should == 0
128
+ expect(v1).to eq(1)
129
+ expect(a1).to eq(0)
130
130
  end
131
131
  end
132
132
 
@@ -136,7 +136,7 @@ describe Rufus::Scheduler::Job do
136
136
 
137
137
  job = @scheduler.in('1d', :job => true) {}
138
138
 
139
- job.running?.should == false
139
+ expect(job.running?).to eq(false)
140
140
  end
141
141
 
142
142
  it 'returns true when the job is running in at least one thread' do
@@ -145,7 +145,7 @@ describe Rufus::Scheduler::Job do
145
145
 
146
146
  sleep 0.4
147
147
 
148
- job.running?.should == true
148
+ expect(job.running?).to eq(true)
149
149
  end
150
150
  end
151
151
 
@@ -155,7 +155,7 @@ describe Rufus::Scheduler::Job do
155
155
 
156
156
  job = @scheduler.schedule_in('1d') {}
157
157
 
158
- job.scheduled?.should == true
158
+ expect(job.scheduled?).to eq(true)
159
159
  end
160
160
 
161
161
  it 'returns false when the job is not scheduled' do
@@ -164,7 +164,7 @@ describe Rufus::Scheduler::Job do
164
164
 
165
165
  sleep 0.4
166
166
 
167
- job.scheduled?.should == false
167
+ expect(job.scheduled?).to eq(false)
168
168
  end
169
169
 
170
170
  it 'returns true for repeat jobs that are running' do
@@ -173,8 +173,8 @@ describe Rufus::Scheduler::Job do
173
173
 
174
174
  sleep 1
175
175
 
176
- job.running?.should == true
177
- job.scheduled?.should == true
176
+ expect(job.running?).to eq(true)
177
+ expect(job.scheduled?).to eq(true)
178
178
  end
179
179
  end
180
180
 
@@ -192,7 +192,7 @@ describe Rufus::Scheduler::Job do
192
192
 
193
193
  sleep 0.8
194
194
 
195
- counter.should == 2
195
+ expect(counter).to eq(2)
196
196
  end
197
197
  end
198
198
 
@@ -215,7 +215,7 @@ describe Rufus::Scheduler::Job do
215
215
 
216
216
  job.call(true)
217
217
 
218
- $err.should == 'Rufus::Scheduler::InJob 1d again'
218
+ expect($err).to eq('Rufus::Scheduler::InJob 1d again')
219
219
  end
220
220
  end
221
221
 
@@ -233,11 +233,11 @@ describe Rufus::Scheduler::Job do
233
233
  #job.call(false)
234
234
  job.call # false is the default
235
235
 
236
- false.should == true
236
+ expect(false).to eq(true)
237
237
 
238
238
  rescue => ex
239
239
 
240
- ex.message.should == 'fast'
240
+ expect(ex.message).to eq('fast')
241
241
  end
242
242
  end
243
243
  end
@@ -256,7 +256,7 @@ describe Rufus::Scheduler::Job do
256
256
 
257
257
  sleep 3
258
258
 
259
- job[:counter].should > 1
259
+ expect(job[:counter]).to be > 1
260
260
  end
261
261
  end
262
262
 
@@ -266,7 +266,7 @@ describe Rufus::Scheduler::Job do
266
266
 
267
267
  job = @scheduler.schedule_in '1s' do; end
268
268
 
269
- job[:nada].should == nil
269
+ expect(job[:nada]).to eq(nil)
270
270
  end
271
271
 
272
272
  it 'returns the value of a job-local variable' do
@@ -274,7 +274,7 @@ describe Rufus::Scheduler::Job do
274
274
  job = @scheduler.schedule_in '1s' do; end
275
275
  job[:x] = :y
276
276
 
277
- job[:x].should == :y
277
+ expect(job[:x]).to eq(:y)
278
278
  end
279
279
  end
280
280
 
@@ -285,7 +285,7 @@ describe Rufus::Scheduler::Job do
285
285
  job = @scheduler.schedule_in '1s' do; end
286
286
  job[:x] = :y
287
287
 
288
- job.key?(:x).should == true
288
+ expect(job.key?(:x)).to eq(true)
289
289
  end
290
290
  end
291
291
 
@@ -298,7 +298,7 @@ describe Rufus::Scheduler::Job do
298
298
  job['hello'] = :z
299
299
  job[123] = {}
300
300
 
301
- job.keys.sort_by { |k| k.to_s }.should == [ 123, 'hello', :x ]
301
+ expect(job.keys.sort_by { |k| k.to_s }).to eq([ 123, 'hello', :x ])
302
302
  end
303
303
  end
304
304
  end
@@ -309,21 +309,21 @@ describe Rufus::Scheduler::Job do
309
309
 
310
310
  job = @scheduler.in '10d', :job => true, :tag => 't0' do; end
311
311
 
312
- job.tags.should == %w[ t0 ]
312
+ expect(job.tags).to eq(%w[ t0 ])
313
313
  end
314
314
 
315
315
  it 'accepts an array of tags' do
316
316
 
317
317
  job = @scheduler.in '10d', :job => true, :tag => %w[ t0 t1 ] do; end
318
318
 
319
- job.tags.should == %w[ t0 t1 ]
319
+ expect(job.tags).to eq(%w[ t0 t1 ])
320
320
  end
321
321
 
322
322
  it 'turns tags into strings' do
323
323
 
324
324
  job = @scheduler.in '10d', :job => true, :tags => [ 1, 2 ] do; end
325
325
 
326
- job.tags.should == %w[ 1 2 ]
326
+ expect(job.tags).to eq(%w[ 1 2 ])
327
327
  end
328
328
  end
329
329
 
@@ -338,11 +338,11 @@ describe Rufus::Scheduler::Job do
338
338
 
339
339
  sleep 0.4
340
340
 
341
- job.threads.first.should == @scheduler.thread
341
+ expect(job.threads.first).to eq(@scheduler.thread)
342
342
 
343
343
  sleep 1.4
344
344
 
345
- job.threads.size.should == 0
345
+ expect(job.threads.size).to eq(0)
346
346
  end
347
347
  end
348
348
 
@@ -357,11 +357,11 @@ describe Rufus::Scheduler::Job do
357
357
 
358
358
  sleep 0.4
359
359
 
360
- job.threads.first.should_not == @scheduler.thread
360
+ expect(job.threads.first).not_to eq(@scheduler.thread)
361
361
 
362
362
  sleep 1.4
363
363
 
364
- job.threads.size.should == 0
364
+ expect(job.threads.size).to eq(0)
365
365
  end
366
366
  end
367
367
 
@@ -378,7 +378,7 @@ describe Rufus::Scheduler::Job do
378
378
 
379
379
  sleep 3
380
380
 
381
- job.threads.size.should > 1
381
+ expect(job.threads.size).to be > 1
382
382
  end
383
383
  end
384
384
 
@@ -393,7 +393,7 @@ describe Rufus::Scheduler::Job do
393
393
 
394
394
  sleep 3
395
395
 
396
- job.threads.size.should == 1
396
+ expect(job.threads.size).to eq(1)
397
397
  end
398
398
  end
399
399
  end
@@ -416,14 +416,14 @@ describe Rufus::Scheduler::Job do
416
416
  sleep 0.7
417
417
 
418
418
  if j0.threads.any?
419
- j0.threads.size.should == 1
420
- j1.threads.size.should == 0
419
+ expect(j0.threads.size).to eq(1)
420
+ expect(j1.threads.size).to eq(0)
421
421
  else
422
- j0.threads.size.should == 0
423
- j1.threads.size.should == 1
422
+ expect(j0.threads.size).to eq(0)
423
+ expect(j1.threads.size).to eq(1)
424
424
  end
425
425
 
426
- @scheduler.mutexes.keys.should == %w[ vladivostok ]
426
+ expect(@scheduler.mutexes.keys).to eq(%w[ vladivostok ])
427
427
  end
428
428
  end
429
429
 
@@ -439,14 +439,14 @@ describe Rufus::Scheduler::Job do
439
439
  sleep 0.7
440
440
 
441
441
  if j0.threads.any?
442
- j0.threads.size.should == 1
443
- j1.threads.size.should == 0
442
+ expect(j0.threads.size).to eq(1)
443
+ expect(j1.threads.size).to eq(0)
444
444
  else
445
- j0.threads.size.should == 0
446
- j1.threads.size.should == 1
445
+ expect(j0.threads.size).to eq(0)
446
+ expect(j1.threads.size).to eq(1)
447
447
  end
448
448
 
449
- @scheduler.mutexes.keys.should == []
449
+ expect(@scheduler.mutexes.keys).to eq([])
450
450
  end
451
451
  end
452
452
 
@@ -466,14 +466,14 @@ describe Rufus::Scheduler::Job do
466
466
  sleep 0.7
467
467
 
468
468
  if j0.threads.any?
469
- j0.threads.size.should == 1
470
- j1.threads.size.should == 0
469
+ expect(j0.threads.size).to eq(1)
470
+ expect(j1.threads.size).to eq(0)
471
471
  else
472
- j0.threads.size.should == 0
473
- j1.threads.size.should == 1
472
+ expect(j0.threads.size).to eq(0)
473
+ expect(j1.threads.size).to eq(1)
474
474
  end
475
475
 
476
- @scheduler.mutexes.keys.sort.should == %w[ a b ]
476
+ expect(@scheduler.mutexes.keys.sort).to eq(%w[ a b ])
477
477
  end
478
478
  end
479
479
  end
@@ -498,8 +498,8 @@ describe Rufus::Scheduler::Job do
498
498
 
499
499
  sleep(3)
500
500
 
501
- counter.should == 1
502
- toe.class.should == Rufus::Scheduler::TimeoutError
501
+ expect(counter).to eq(1)
502
+ expect(toe.class).to eq(Rufus::Scheduler::TimeoutError)
503
503
  end
504
504
 
505
505
  it 'interrupts the job it is stashed to (point in time)' do
@@ -518,7 +518,7 @@ describe Rufus::Scheduler::Job do
518
518
 
519
519
  sleep(3)
520
520
 
521
- counter.should == 1
521
+ expect(counter).to eq(1)
522
522
  end
523
523
 
524
524
  it 'starts timing when the job enters successfully all its mutexes' do
@@ -542,11 +542,11 @@ describe Rufus::Scheduler::Job do
542
542
 
543
543
  sleep 3
544
544
 
545
- t0.should <= t1
545
+ expect(t0).to be <= t1
546
546
 
547
547
  d = t2 - t1
548
- d.should >= 1.0
549
- d.should < 1.5
548
+ expect(d).to be >= 1.0
549
+ expect(d).to be < 1.5
550
550
  end
551
551
 
552
552
  it 'emits the timeout information to $stderr (default #on_error)' do
@@ -557,7 +557,7 @@ describe Rufus::Scheduler::Job do
557
557
 
558
558
  sleep 2
559
559
 
560
- $stderr.string.should match(/Rufus::Scheduler::TimeoutError/)
560
+ expect($stderr.string).to match(/Rufus::Scheduler::TimeoutError/)
561
561
  end
562
562
 
563
563
  it 'does not prevent a repeat job from recurring' do
@@ -571,7 +571,7 @@ describe Rufus::Scheduler::Job do
571
571
 
572
572
  sleep 3
573
573
 
574
- counter.should > 1
574
+ expect(counter).to be > 1
575
575
  end
576
576
  end
577
577
 
@@ -583,7 +583,7 @@ describe Rufus::Scheduler::Job do
583
583
 
584
584
  job = @scheduler.schedule_every '5m' do; end
585
585
 
586
- job.last_work_time.should == 0.0
586
+ expect(job.last_work_time).to eq(0.0)
587
587
  end
588
588
 
589
589
  it 'keeps track of how long the work was upon last trigger' do
@@ -595,8 +595,8 @@ describe Rufus::Scheduler::Job do
595
595
 
596
596
  sleep 2
597
597
 
598
- job.last_work_time.should >= 0.7
599
- job.last_work_time.should < 0.8
598
+ expect(job.last_work_time).to be >= 0.7
599
+ expect(job.last_work_time).to be < 0.8
600
600
  end
601
601
  end
602
602
 
@@ -606,7 +606,7 @@ describe Rufus::Scheduler::Job do
606
606
 
607
607
  job = @scheduler.schedule_every '5m' do; end
608
608
 
609
- job.mean_work_time.should == 0.0
609
+ expect(job.mean_work_time).to eq(0.0)
610
610
  end
611
611
 
612
612
  it 'gathers work times and computes the mean' do
@@ -620,10 +620,10 @@ describe Rufus::Scheduler::Job do
620
620
 
621
621
  sleep 4.6
622
622
 
623
- job.last_work_time.should >= 0.08
624
- job.last_work_time.should < 0.099
625
- job.mean_work_time.should > 0.05
626
- job.mean_work_time.should < 0.06
623
+ expect(job.last_work_time).to be >= 0.08
624
+ expect(job.last_work_time).to be < 0.099
625
+ expect(job.mean_work_time).to be > 0.05
626
+ expect(job.mean_work_time).to be < 0.06
627
627
  end
628
628
  end
629
629
  end
@@ -25,7 +25,7 @@ describe Rufus::Scheduler do
25
25
  line = File.read('.rufus-scheduler.lock')
26
26
 
27
27
  #p line
28
- line.should match(/pid: #{$$}/)
28
+ expect(line).to match(/pid: #{$$}/)
29
29
  end
30
30
 
31
31
  it '"flocks" the lock file' do
@@ -34,7 +34,7 @@ describe Rufus::Scheduler do
34
34
 
35
35
  f = File.new('.rufus-scheduler.lock', 'a')
36
36
 
37
- f.flock(File::LOCK_NB | File::LOCK_EX).should == false
37
+ expect(f.flock(File::LOCK_NB | File::LOCK_EX)).to eq(false)
38
38
  end
39
39
 
40
40
  it 'prevents newer schedulers from starting' do
@@ -42,8 +42,8 @@ describe Rufus::Scheduler do
42
42
  s0 = Rufus::Scheduler.new :lockfile => '.rufus-scheduler.lock'
43
43
  s1 = Rufus::Scheduler.new :lockfile => '.rufus-scheduler.lock'
44
44
 
45
- s0.started_at.should_not == nil
46
- s1.started_at.should == nil
45
+ expect(s0.started_at).not_to eq(nil)
46
+ expect(s1.started_at).to eq(nil)
47
47
  end
48
48
 
49
49
  it 'releases the lockfile when shutting down' do
@@ -54,7 +54,7 @@ describe Rufus::Scheduler do
54
54
 
55
55
  f = File.new('.rufus-scheduler.lock', 'a')
56
56
 
57
- f.flock(File::LOCK_NB | File::LOCK_EX).should == 0
57
+ expect(f.flock(File::LOCK_NB | File::LOCK_EX)).to eq(0)
58
58
  end
59
59
  end
60
60
  end
data/spec/parse_spec.rb CHANGED
@@ -12,70 +12,112 @@ describe Rufus::Scheduler do
12
12
 
13
13
  describe '.parse' do
14
14
 
15
- def parse(s)
16
- Rufus::Scheduler.parse(s)
15
+ def parse(s, opts={})
16
+ Rufus::Scheduler.parse(s, opts)
17
17
  end
18
18
 
19
19
  it 'parses duration strings' do
20
20
 
21
- parse('1.0d1.0w1.0d').should == 777600.0
21
+ expect(parse('1.0d1.0w1.0d')).to eq(777600.0)
22
22
  end
23
23
 
24
24
  it 'parses datetimes' do
25
25
 
26
26
  # local
27
27
 
28
- parse('Sun Nov 18 16:01:00 2012').strftime('%c').should ==
28
+ expect(parse('Sun Nov 18 16:01:00 2012').strftime('%c')).to eq(
29
29
  'Sun Nov 18 16:01:00 2012'
30
+ )
30
31
  end
31
32
 
32
33
  it 'parses datetimes with timezones' do
33
34
 
34
- parse('Sun Nov 18 16:01:00 2012 Japan').getutc.strftime('%c').should ==
35
+ expect(parse('Sun Nov 18 16:01:00 2012 Japan').getutc.strftime('%c')).to eq(
35
36
  'Sun Nov 18 07:01:00 2012'
37
+ )
36
38
 
37
- parse('Sun Nov 18 16:01:00 2012 Zulu').getutc.strftime('%c').should ==
39
+ expect(parse('Sun Nov 18 16:01:00 2012 Zulu').getutc.strftime('%c')).to eq(
38
40
  'Sun Nov 18 16:01:00 2012'
41
+ )
39
42
 
40
- parse('Sun Nov 18 16:01:00 Japan 2012').getutc.strftime('%c').should ==
43
+ expect(parse('Sun Nov 18 16:01:00 Japan 2012').getutc.strftime('%c')).to eq(
41
44
  'Sun Nov 18 07:01:00 2012'
45
+ )
42
46
 
43
- parse('Japan Sun Nov 18 16:01:00 2012').getutc.strftime('%c').should ==
47
+ expect(parse('Japan Sun Nov 18 16:01:00 2012').getutc.strftime('%c')).to eq(
44
48
  'Sun Nov 18 07:01:00 2012'
49
+ )
45
50
  end
46
51
 
47
52
  it 'parses datetimes with named timezones' do
48
53
 
49
- parse(
54
+ expect(parse(
50
55
  'Sun Nov 18 16:01:00 2012 Europe/Berlin'
51
- ).strftime('%c %z').should ==
56
+ ).strftime('%c %z')).to eq(
52
57
  'Sun Nov 18 15:01:00 2012 +0000'
58
+ )
53
59
  end
54
60
 
55
61
  it 'parses datetimes (with the local timezone implicitely)' do
56
62
 
57
63
  localzone = Time.now.strftime('%z')
58
64
 
59
- parse('Sun Nov 18 16:01:00 2012').strftime('%c %z').should ==
65
+ expect(parse('Sun Nov 18 16:01:00 2012').strftime('%c %z')).to eq(
60
66
  "Sun Nov 18 16:01:00 2012 #{localzone}"
67
+ )
61
68
  end
62
69
 
63
70
  it 'parses cronlines' do
64
71
 
65
72
  out = parse('* * * * *')
66
73
 
67
- out.class.should == Rufus::Scheduler::CronLine
68
- out.original.should == '* * * * *'
74
+ expect(out.class).to eq(Rufus::Scheduler::CronLine)
75
+ expect(out.original).to eq('* * * * *')
69
76
 
70
- parse('10 23 * * *').class.should == Rufus::Scheduler::CronLine
71
- parse('* 23 * * *').class.should == Rufus::Scheduler::CronLine
77
+ expect(parse('10 23 * * *').class).to eq(Rufus::Scheduler::CronLine)
78
+ expect(parse('* 23 * * *').class).to eq(Rufus::Scheduler::CronLine)
72
79
  end
73
80
 
74
81
  it 'raises on unparseable input' do
75
82
 
76
- lambda {
83
+ expect {
77
84
  parse('nada')
78
- }.should raise_error(ArgumentError, 'couldn\'t parse "nada"')
85
+ }.to raise_error(ArgumentError, 'couldn\'t parse "nada"')
86
+ end
87
+
88
+ it 'does not use Chronic if not present' do
89
+
90
+ t = parse('next monday 7 PM')
91
+
92
+ n = Time.now
93
+
94
+ expect(t.strftime('%Y-%m-%d %H:%M:%S')).to eq(
95
+ n.strftime('%Y-%m-%d') + ' 19:00:00'
96
+ )
97
+ end
98
+
99
+ it 'uses Chronic if present' do
100
+
101
+ with_chronic do
102
+
103
+ t = parse('next monday 7 PM')
104
+
105
+ expect(t.wday).to eq(1)
106
+ expect(t.hour).to eq(19)
107
+ expect(t.min).to eq(0)
108
+ expect(t).to be > Time.now
109
+ end
110
+ end
111
+
112
+ it 'passes options to Chronic' do
113
+
114
+ with_chronic do
115
+
116
+ t = parse('monday', :context => :past)
117
+
118
+ expect(t.wday).to eq(1)
119
+ expect(t).to be < Time.now
120
+ end
79
121
  end
80
122
  end
81
123
 
@@ -87,54 +129,54 @@ describe Rufus::Scheduler do
87
129
 
88
130
  it 'parses duration strings' do
89
131
 
90
- pd('-1.0d1.0w1.0d').should == -777600.0
91
- pd('-1d1w1d').should == -777600.0
92
- pd('-1w2d').should == -777600.0
93
- pd('-1h10s').should == -3610.0
94
- pd('-1h').should == -3600.0
95
- pd('-5.').should == -5.0
96
- pd('-2.5s').should == -2.5
97
- pd('-1s').should == -1.0
98
- pd('-500').should == -500
99
- pd('').should == 0.0
100
- pd('5.0').should == 5.0
101
- pd('0.5').should == 0.5
102
- pd('.5').should == 0.5
103
- pd('5.').should == 5.0
104
- pd('500').should == 500
105
- pd('1000').should == 1000
106
- pd('1').should == 1.0
107
- pd('1s').should == 1.0
108
- pd('2.5s').should == 2.5
109
- pd('1h').should == 3600.0
110
- pd('1h10s').should == 3610.0
111
- pd('1w2d').should == 777600.0
112
- pd('1d1w1d').should == 777600.0
113
- pd('1.0d1.0w1.0d').should == 777600.0
114
-
115
- pd('.5m').should == 30.0
116
- pd('5.m').should == 300.0
117
- pd('1m.5s').should == 60.5
118
- pd('-.5m').should == -30.0
119
-
120
- pd('1').should == 1
121
- pd('0.1').should == 0.1
122
- pd('1s').should == 1
132
+ expect(pd('-1.0d1.0w1.0d')).to eq(-777600.0)
133
+ expect(pd('-1d1w1d')).to eq(-777600.0)
134
+ expect(pd('-1w2d')).to eq(-777600.0)
135
+ expect(pd('-1h10s')).to eq(-3610.0)
136
+ expect(pd('-1h')).to eq(-3600.0)
137
+ expect(pd('-5.')).to eq(-5.0)
138
+ expect(pd('-2.5s')).to eq(-2.5)
139
+ expect(pd('-1s')).to eq(-1.0)
140
+ expect(pd('-500')).to eq(-500)
141
+ expect(pd('')).to eq(0.0)
142
+ expect(pd('5.0')).to eq(5.0)
143
+ expect(pd('0.5')).to eq(0.5)
144
+ expect(pd('.5')).to eq(0.5)
145
+ expect(pd('5.')).to eq(5.0)
146
+ expect(pd('500')).to eq(500)
147
+ expect(pd('1000')).to eq(1000)
148
+ expect(pd('1')).to eq(1.0)
149
+ expect(pd('1s')).to eq(1.0)
150
+ expect(pd('2.5s')).to eq(2.5)
151
+ expect(pd('1h')).to eq(3600.0)
152
+ expect(pd('1h10s')).to eq(3610.0)
153
+ expect(pd('1w2d')).to eq(777600.0)
154
+ expect(pd('1d1w1d')).to eq(777600.0)
155
+ expect(pd('1.0d1.0w1.0d')).to eq(777600.0)
156
+
157
+ expect(pd('.5m')).to eq(30.0)
158
+ expect(pd('5.m')).to eq(300.0)
159
+ expect(pd('1m.5s')).to eq(60.5)
160
+ expect(pd('-.5m')).to eq(-30.0)
161
+
162
+ expect(pd('1')).to eq(1)
163
+ expect(pd('0.1')).to eq(0.1)
164
+ expect(pd('1s')).to eq(1)
123
165
  end
124
166
 
125
167
  it 'calls #to_s on its input' do
126
168
 
127
- pd(0.1).should == 0.1
169
+ expect(pd(0.1)).to eq(0.1)
128
170
  end
129
171
 
130
172
  it 'raises on wrong duration strings' do
131
173
 
132
- lambda { pd('-') }.should raise_error(ArgumentError)
133
- lambda { pd('h') }.should raise_error(ArgumentError)
134
- lambda { pd('whatever') }.should raise_error(ArgumentError)
135
- lambda { pd('hms') }.should raise_error(ArgumentError)
174
+ expect { pd('-') }.to raise_error(ArgumentError)
175
+ expect { pd('h') }.to raise_error(ArgumentError)
176
+ expect { pd('whatever') }.to raise_error(ArgumentError)
177
+ expect { pd('hms') }.to raise_error(ArgumentError)
136
178
 
137
- lambda { pd(' 1h ') }.should raise_error(ArgumentError)
179
+ expect { pd(' 1h ') }.to raise_error(ArgumentError)
138
180
  end
139
181
  end
140
182
 
@@ -142,7 +184,7 @@ describe Rufus::Scheduler do
142
184
 
143
185
  it 'is still around for libs using it out there' do
144
186
 
145
- Rufus::Scheduler.parse_time_string('1d1w1d').should == 777600.0
187
+ expect(Rufus::Scheduler.parse_time_string('1d1w1d')).to eq(777600.0)
146
188
  end
147
189
  end
148
190
 
@@ -150,7 +192,7 @@ describe Rufus::Scheduler do
150
192
 
151
193
  it 'is still around for libs using it out there' do
152
194
 
153
- Rufus::Scheduler.parse_duration_string('1d1w1d').should == 777600.0
195
+ expect(Rufus::Scheduler.parse_duration_string('1d1w1d')).to eq(777600.0)
154
196
  end
155
197
  end
156
198
 
@@ -162,32 +204,32 @@ describe Rufus::Scheduler do
162
204
 
163
205
  it 'turns integers into duration strings' do
164
206
 
165
- td(0).should == '0s'
166
- td(60).should == '1m'
167
- td(61).should == '1m1s'
168
- td(3661).should == '1h1m1s'
169
- td(24 * 3600).should == '1d'
170
- td(7 * 24 * 3600 + 1).should == '1w1s'
171
- td(30 * 24 * 3600 + 1).should == '4w2d1s'
207
+ expect(td(0)).to eq('0s')
208
+ expect(td(60)).to eq('1m')
209
+ expect(td(61)).to eq('1m1s')
210
+ expect(td(3661)).to eq('1h1m1s')
211
+ expect(td(24 * 3600)).to eq('1d')
212
+ expect(td(7 * 24 * 3600 + 1)).to eq('1w1s')
213
+ expect(td(30 * 24 * 3600 + 1)).to eq('4w2d1s')
172
214
  end
173
215
 
174
216
  it 'ignores seconds and milliseconds if :drop_seconds => true' do
175
217
 
176
- td(0, :drop_seconds => true).should == '0m'
177
- td(5, :drop_seconds => true).should == '0m'
178
- td(61, :drop_seconds => true).should == '1m'
218
+ expect(td(0, :drop_seconds => true)).to eq('0m')
219
+ expect(td(5, :drop_seconds => true)).to eq('0m')
220
+ expect(td(61, :drop_seconds => true)).to eq('1m')
179
221
  end
180
222
 
181
223
  it 'displays months if :months => true' do
182
224
 
183
- td(1, :months => true).should == '1s'
184
- td(30 * 24 * 3600 + 1, :months => true).should == '1M1s'
225
+ expect(td(1, :months => true)).to eq('1s')
226
+ expect(td(30 * 24 * 3600 + 1, :months => true)).to eq('1M1s')
185
227
  end
186
228
 
187
229
  it 'turns floats into duration strings' do
188
230
 
189
- td(0.1).should == '100'
190
- td(1.1).should == '1s100'
231
+ expect(td(0.1)).to eq('100')
232
+ expect(td(1.1)).to eq('1s100')
191
233
  end
192
234
  end
193
235
 
@@ -199,20 +241,20 @@ describe Rufus::Scheduler do
199
241
 
200
242
  it 'turns integers duration hashes' do
201
243
 
202
- tdh(0).should == {}
203
- tdh(60).should == { :m => 1 }
244
+ expect(tdh(0)).to eq({})
245
+ expect(tdh(60)).to eq({ :m => 1 })
204
246
  end
205
247
 
206
248
  it 'turns floats duration hashes' do
207
249
 
208
- tdh(0.128).should == { :ms => 128 }
209
- tdh(60.127).should == { :m => 1, :ms => 127 }
250
+ expect(tdh(0.128)).to eq({ :ms => 128 })
251
+ expect(tdh(60.127)).to eq({ :m => 1, :ms => 127 })
210
252
  end
211
253
 
212
254
  it 'drops seconds and milliseconds if :drop_seconds => true' do
213
255
 
214
- tdh(61.127).should == { :m => 1, :s => 1, :ms => 127 }
215
- tdh(61.127, :drop_seconds => true).should == { :m => 1 }
256
+ expect(tdh(61.127)).to eq({ :m => 1, :s => 1, :ms => 127 })
257
+ expect(tdh(61.127, :drop_seconds => true)).to eq({ :m => 1 })
216
258
  end
217
259
  end
218
260
  end