rufus-scheduler 3.0.0 → 3.0.9

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/parse_spec.rb CHANGED
@@ -12,70 +12,116 @@ 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
+ )
50
+
51
+ expect(parse('Sun Nov 18 16:01:00 2012 America/New_York').getutc.strftime('%c')).to eq(
52
+ 'Sun Nov 18 21:01:00 2012'
53
+ )
45
54
  end
46
55
 
47
56
  it 'parses datetimes with named timezones' do
48
57
 
49
- parse(
58
+ expect(parse(
50
59
  'Sun Nov 18 16:01:00 2012 Europe/Berlin'
51
- ).strftime('%c %z').should ==
60
+ ).strftime('%c %z')).to eq(
52
61
  'Sun Nov 18 15:01:00 2012 +0000'
62
+ )
53
63
  end
54
64
 
55
65
  it 'parses datetimes (with the local timezone implicitely)' do
56
66
 
57
67
  localzone = Time.now.strftime('%z')
58
68
 
59
- parse('Sun Nov 18 16:01:00 2012').strftime('%c %z').should ==
69
+ expect(parse('Sun Nov 18 16:01:00 2012').strftime('%c %z')).to eq(
60
70
  "Sun Nov 18 16:01:00 2012 #{localzone}"
71
+ )
61
72
  end
62
73
 
63
74
  it 'parses cronlines' do
64
75
 
65
76
  out = parse('* * * * *')
66
77
 
67
- out.class.should == Rufus::Scheduler::CronLine
68
- out.original.should == '* * * * *'
78
+ expect(out.class).to eq(Rufus::Scheduler::CronLine)
79
+ expect(out.original).to eq('* * * * *')
69
80
 
70
- parse('10 23 * * *').class.should == Rufus::Scheduler::CronLine
71
- parse('* 23 * * *').class.should == Rufus::Scheduler::CronLine
81
+ expect(parse('10 23 * * *').class).to eq(Rufus::Scheduler::CronLine)
82
+ expect(parse('* 23 * * *').class).to eq(Rufus::Scheduler::CronLine)
72
83
  end
73
84
 
74
85
  it 'raises on unparseable input' do
75
86
 
76
- lambda {
87
+ expect {
77
88
  parse('nada')
78
- }.should raise_error(ArgumentError, 'couldn\'t parse "nada"')
89
+ }.to raise_error(ArgumentError, 'couldn\'t parse "nada"')
90
+ end
91
+
92
+ it 'does not use Chronic if not present' do
93
+
94
+ t = parse('next monday 7 PM')
95
+
96
+ n = Time.now
97
+
98
+ expect(t.strftime('%Y-%m-%d %H:%M:%S')).to eq(
99
+ n.strftime('%Y-%m-%d') + ' 19:00:00'
100
+ )
101
+ end
102
+
103
+ it 'uses Chronic if present' do
104
+
105
+ with_chronic do
106
+
107
+ t = parse('next monday 7 PM')
108
+
109
+ expect(t.wday).to eq(1)
110
+ expect(t.hour).to eq(19)
111
+ expect(t.min).to eq(0)
112
+ expect(t).to be > Time.now
113
+ end
114
+ end
115
+
116
+ it 'passes options to Chronic' do
117
+
118
+ with_chronic do
119
+
120
+ t = parse('monday', :context => :past)
121
+
122
+ expect(t.wday).to eq(1)
123
+ expect(t).to be < Time.now
124
+ end
79
125
  end
80
126
  end
81
127
 
@@ -87,54 +133,70 @@ describe Rufus::Scheduler do
87
133
 
88
134
  it 'parses duration strings' do
89
135
 
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
136
+ expect(pd('-1.0d1.0w1.0d')).to eq(-777600.0)
137
+ expect(pd('-1d1w1d')).to eq(-777600.0)
138
+ expect(pd('-1w2d')).to eq(-777600.0)
139
+ expect(pd('-1h10s')).to eq(-3610.0)
140
+ expect(pd('-1h')).to eq(-3600.0)
141
+ expect(pd('-5.')).to eq(-5.0)
142
+ expect(pd('-2.5s')).to eq(-2.5)
143
+ expect(pd('-1s')).to eq(-1.0)
144
+ expect(pd('-500')).to eq(-500)
145
+ expect(pd('')).to eq(0.0)
146
+ expect(pd('5.0')).to eq(5.0)
147
+ expect(pd('0.5')).to eq(0.5)
148
+ expect(pd('.5')).to eq(0.5)
149
+ expect(pd('5.')).to eq(5.0)
150
+ expect(pd('500')).to eq(500)
151
+ expect(pd('1000')).to eq(1000)
152
+ expect(pd('1')).to eq(1.0)
153
+ expect(pd('1s')).to eq(1.0)
154
+ expect(pd('2.5s')).to eq(2.5)
155
+ expect(pd('1h')).to eq(3600.0)
156
+ expect(pd('1h10s')).to eq(3610.0)
157
+ expect(pd('1w2d')).to eq(777600.0)
158
+ expect(pd('1d1w1d')).to eq(777600.0)
159
+ expect(pd('1.0d1.0w1.0d')).to eq(777600.0)
160
+
161
+ expect(pd('.5m')).to eq(30.0)
162
+ expect(pd('5.m')).to eq(300.0)
163
+ expect(pd('1m.5s')).to eq(60.5)
164
+ expect(pd('-.5m')).to eq(-30.0)
165
+
166
+ expect(pd('1')).to eq(1)
167
+ expect(pd('0.1')).to eq(0.1)
168
+ expect(pd('1s')).to eq(1)
123
169
  end
124
170
 
125
171
  it 'calls #to_s on its input' do
126
172
 
127
- pd(0.1).should == 0.1
173
+ expect(pd(0.1)).to eq(0.1)
128
174
  end
129
175
 
130
176
  it 'raises on wrong duration strings' do
131
177
 
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)
178
+ expect { pd('-') }.to raise_error(ArgumentError)
179
+ expect { pd('h') }.to raise_error(ArgumentError)
180
+ expect { pd('whatever') }.to raise_error(ArgumentError)
181
+ expect { pd('hms') }.to raise_error(ArgumentError)
182
+
183
+ expect { pd(' 1h ') }.to raise_error(ArgumentError)
184
+ end
185
+ end
186
+
187
+ describe '.parse_time_string -> .parse_duration' do
188
+
189
+ it 'is still around for libs using it out there' do
190
+
191
+ expect(Rufus::Scheduler.parse_time_string('1d1w1d')).to eq(777600.0)
192
+ end
193
+ end
194
+
195
+ describe '.parse_duration_string -> .parse_duration' do
196
+
197
+ it 'is still around for libs using it out there' do
136
198
 
137
- lambda { pd(' 1h ') }.should raise_error(ArgumentError)
199
+ expect(Rufus::Scheduler.parse_duration_string('1d1w1d')).to eq(777600.0)
138
200
  end
139
201
  end
140
202
 
@@ -146,32 +208,32 @@ describe Rufus::Scheduler do
146
208
 
147
209
  it 'turns integers into duration strings' do
148
210
 
149
- td(0).should == '0s'
150
- td(60).should == '1m'
151
- td(61).should == '1m1s'
152
- td(3661).should == '1h1m1s'
153
- td(24 * 3600).should == '1d'
154
- td(7 * 24 * 3600 + 1).should == '1w1s'
155
- td(30 * 24 * 3600 + 1).should == '4w2d1s'
211
+ expect(td(0)).to eq('0s')
212
+ expect(td(60)).to eq('1m')
213
+ expect(td(61)).to eq('1m1s')
214
+ expect(td(3661)).to eq('1h1m1s')
215
+ expect(td(24 * 3600)).to eq('1d')
216
+ expect(td(7 * 24 * 3600 + 1)).to eq('1w1s')
217
+ expect(td(30 * 24 * 3600 + 1)).to eq('4w2d1s')
156
218
  end
157
219
 
158
220
  it 'ignores seconds and milliseconds if :drop_seconds => true' do
159
221
 
160
- td(0, :drop_seconds => true).should == '0m'
161
- td(5, :drop_seconds => true).should == '0m'
162
- td(61, :drop_seconds => true).should == '1m'
222
+ expect(td(0, :drop_seconds => true)).to eq('0m')
223
+ expect(td(5, :drop_seconds => true)).to eq('0m')
224
+ expect(td(61, :drop_seconds => true)).to eq('1m')
163
225
  end
164
226
 
165
227
  it 'displays months if :months => true' do
166
228
 
167
- td(1, :months => true).should == '1s'
168
- td(30 * 24 * 3600 + 1, :months => true).should == '1M1s'
229
+ expect(td(1, :months => true)).to eq('1s')
230
+ expect(td(30 * 24 * 3600 + 1, :months => true)).to eq('1M1s')
169
231
  end
170
232
 
171
233
  it 'turns floats into duration strings' do
172
234
 
173
- td(0.1).should == '100'
174
- td(1.1).should == '1s100'
235
+ expect(td(0.1)).to eq('100')
236
+ expect(td(1.1)).to eq('1s100')
175
237
  end
176
238
  end
177
239
 
@@ -183,20 +245,20 @@ describe Rufus::Scheduler do
183
245
 
184
246
  it 'turns integers duration hashes' do
185
247
 
186
- tdh(0).should == {}
187
- tdh(60).should == { :m => 1 }
248
+ expect(tdh(0)).to eq({})
249
+ expect(tdh(60)).to eq({ :m => 1 })
188
250
  end
189
251
 
190
252
  it 'turns floats duration hashes' do
191
253
 
192
- tdh(0.128).should == { :ms => 128 }
193
- tdh(60.127).should == { :m => 1, :ms => 127 }
254
+ expect(tdh(0.128)).to eq({ :ms => 128 })
255
+ expect(tdh(60.127)).to eq({ :m => 1, :ms => 127 })
194
256
  end
195
257
 
196
258
  it 'drops seconds and milliseconds if :drop_seconds => true' do
197
259
 
198
- tdh(61.127).should == { :m => 1, :s => 1, :ms => 127 }
199
- tdh(61.127, :drop_seconds => true).should == { :m => 1 }
260
+ expect(tdh(61.127)).to eq({ :m => 1, :s => 1, :ms => 127 })
261
+ expect(tdh(61.127, :drop_seconds => true)).to eq({ :m => 1 })
200
262
  end
201
263
  end
202
264
  end
@@ -21,9 +21,9 @@ describe Rufus::Scheduler do
21
21
 
22
22
  it 'raises if the block to schedule is missing' do
23
23
 
24
- lambda {
24
+ expect {
25
25
  @scheduler.at(Time.now + 3600)
26
- }.should raise_error(ArgumentError)
26
+ }.to raise_error(ArgumentError)
27
27
  end
28
28
 
29
29
  it 'returns a job id' do
@@ -32,8 +32,8 @@ describe Rufus::Scheduler do
32
32
  @scheduler.at(Time.now + 3600) do
33
33
  end
34
34
 
35
- job_id.class.should == String
36
- job_id.should match(/^at_/)
35
+ expect(job_id.class).to eq(String)
36
+ expect(job_id).to match(/^at_/)
37
37
  end
38
38
 
39
39
  it 'returns a job if :job => true' do
@@ -42,7 +42,7 @@ describe Rufus::Scheduler do
42
42
  @scheduler.at(Time.now + 3600, :job => true) do
43
43
  end
44
44
 
45
- job.class.should == Rufus::Scheduler::AtJob
45
+ expect(job.class).to eq(Rufus::Scheduler::AtJob)
46
46
  end
47
47
 
48
48
  it 'adds a job' do
@@ -52,9 +52,9 @@ describe Rufus::Scheduler do
52
52
  @scheduler.at(t) do
53
53
  end
54
54
 
55
- @scheduler.jobs.size.should == 1
56
- @scheduler.jobs.first.class.should == Rufus::Scheduler::AtJob
57
- @scheduler.jobs.first.time.should == t
55
+ expect(@scheduler.jobs.size).to eq(1)
56
+ expect(@scheduler.jobs.first.class).to eq(Rufus::Scheduler::AtJob)
57
+ expect(@scheduler.jobs.first.time).to eq(t)
58
58
  end
59
59
 
60
60
  it 'triggers a job' do
@@ -67,7 +67,7 @@ describe Rufus::Scheduler do
67
67
 
68
68
  sleep 0.4
69
69
 
70
- a.should == true
70
+ expect(a).to eq(true)
71
71
  end
72
72
 
73
73
  it 'removes the job after execution' do
@@ -77,7 +77,7 @@ describe Rufus::Scheduler do
77
77
 
78
78
  sleep 0.4
79
79
 
80
- @scheduler.jobs.size.should == 0
80
+ expect(@scheduler.jobs.size).to eq(0)
81
81
  end
82
82
 
83
83
  it 'accepts a Time instance' do
@@ -86,31 +86,60 @@ describe Rufus::Scheduler do
86
86
 
87
87
  job = @scheduler.at(t, :job => true) {}
88
88
 
89
- job.time.should == t
89
+ expect(job.time).to eq(t)
90
90
  end
91
91
 
92
92
  it 'accepts a time string' do
93
93
 
94
94
  job = @scheduler.at('2100-12-12 20:30', :job => true) {}
95
95
 
96
- job.time.should == Time.parse('2100-12-12 20:30')
96
+ expect(job.time).to eq(Time.parse('2100-12-12 20:30'))
97
97
  end
98
98
 
99
99
  it 'accepts a time string with a delta timezone' do
100
100
 
101
101
  job = @scheduler.at('2100-12-12 20:30 -0200', :job => true) {}
102
102
 
103
- job.time.should == Time.parse('2100-12-12 20:30 -0200')
103
+ expect(job.time).to eq(Time.parse('2100-12-12 20:30 -0200'))
104
104
  end
105
105
 
106
106
  it 'accepts a time string with a named timezone' do
107
107
 
108
108
  job = @scheduler.at('2050-12-12 20:30 Europe/Berlin', :job => true) {}
109
109
 
110
- job.time.strftime('%c %z').should == 'Mon Dec 12 19:30:00 2050 +0000'
110
+ expect(job.time.strftime('%c %z')).to eq('Mon Dec 12 19:30:00 2050 +0000')
111
+ end
112
+
113
+ it 'accepts a Chronic string (if Chronic is present)' do
114
+
115
+ with_chronic do
116
+
117
+ job = @scheduler.schedule_at('next tuesday at 12:00') {}
118
+
119
+ expect(job.time.wday).to eq(2)
120
+ expect(job.time.hour).to eq(12)
121
+ expect(job.time.min).to eq(0)
122
+ expect(job.time).to be > Time.now
123
+ end
124
+ end
125
+
126
+ it 'accepts a Chronic string and Chronic options (if Chronic present)' do
127
+
128
+ with_chronic do
129
+
130
+ job =
131
+ @scheduler.schedule_at(
132
+ 'may 27th at 12:00', :now => Time.local(Time.now.year + 2, 1, 1)
133
+ ) {}
134
+
135
+ expect(job.time.year).to eq(Time.now.year + 2)
136
+ expect(job.time.month).to eq(5)
137
+ expect(job.time.day).to eq(27)
138
+ expect(job.time.hour).to eq(12)
139
+ expect(job.time.min).to eq(0)
140
+ end
111
141
  end
112
142
 
113
- it 'accepts a Chronic time string (if Chronic is present)'
114
143
  it 'accepts an ActiveSupport time thinggy'
115
144
  end
116
145
 
@@ -121,8 +150,8 @@ describe Rufus::Scheduler do
121
150
  job = @scheduler.schedule_at(Time.now + 3600) do
122
151
  end
123
152
 
124
- job.class.should == Rufus::Scheduler::AtJob
125
- job.id.should match(/^at_/)
153
+ expect(job.class).to eq(Rufus::Scheduler::AtJob)
154
+ expect(job.id).to match(/^at_/)
126
155
  end
127
156
  end
128
157
  end
@@ -38,16 +38,16 @@ describe Rufus::Scheduler do
38
38
  sleep_until_next_second
39
39
  sleep 0.3 # be sure to be well into the second
40
40
 
41
- counter.should == 2
41
+ expect(counter).to eq(2)
42
42
  end
43
43
 
44
44
  it 'raises if the job frequency is higher than the scheduler frequency' do
45
45
 
46
46
  @scheduler.frequency = 10
47
47
 
48
- lambda {
48
+ expect {
49
49
  @scheduler.cron '* * * * * *' do; end
50
- }.should raise_error(ArgumentError)
50
+ }.to raise_error(ArgumentError)
51
51
  end
52
52
  end
53
53
 
@@ -57,9 +57,9 @@ describe Rufus::Scheduler do
57
57
 
58
58
  job = @scheduler.schedule_cron '* * * * *' do; end
59
59
 
60
- job.class.should == Rufus::Scheduler::CronJob
61
- job.original.should == '* * * * *'
62
- job.job_id.should match(/^cron_/)
60
+ expect(job.class).to eq(Rufus::Scheduler::CronJob)
61
+ expect(job.original).to eq('* * * * *')
62
+ expect(job.job_id).to match(/^cron_/)
63
63
  end
64
64
  end
65
65
  end
@@ -24,8 +24,8 @@ describe Rufus::Scheduler do
24
24
  @scheduler.every(10) do
25
25
  end
26
26
 
27
- @scheduler.jobs.size.should == 1
28
- @scheduler.jobs.first.class.should == Rufus::Scheduler::EveryJob
27
+ expect(@scheduler.jobs.size).to eq(1)
28
+ expect(@scheduler.jobs.first.class).to eq(Rufus::Scheduler::EveryJob)
29
29
  end
30
30
 
31
31
  it 'triggers a job (2 times)' do
@@ -38,7 +38,7 @@ describe Rufus::Scheduler do
38
38
 
39
39
  sleep 2.0
40
40
 
41
- counter.should > 2
41
+ expect(counter).to be > 2
42
42
  end
43
43
 
44
44
  it 'does not remove the job after execution' do
@@ -48,23 +48,23 @@ describe Rufus::Scheduler do
48
48
 
49
49
  sleep 0.9
50
50
 
51
- @scheduler.jobs.size.should == 1
51
+ expect(@scheduler.jobs.size).to eq(1)
52
52
  end
53
53
 
54
54
  it 'raises on negative frequencies' do
55
55
 
56
- lambda {
56
+ expect {
57
57
  @scheduler.every(-1) do
58
58
  end
59
- }.should raise_error(ArgumentError)
59
+ }.to raise_error(ArgumentError)
60
60
  end
61
61
 
62
62
  it 'raises on zero frequencies' do
63
63
 
64
- lambda {
64
+ expect {
65
65
  @scheduler.every(0) do
66
66
  end
67
- }.should raise_error(ArgumentError)
67
+ }.to raise_error(ArgumentError)
68
68
  end
69
69
 
70
70
  it 'does not reschedule if the job was unscheduled' do
@@ -83,16 +83,16 @@ describe Rufus::Scheduler do
83
83
 
84
84
  sleep 1.6
85
85
 
86
- counter.should == c
86
+ expect(counter).to eq(c)
87
87
  end
88
88
 
89
89
  it 'raises if the job frequency is higher than the scheduler frequency' do
90
90
 
91
91
  @scheduler.frequency = 10
92
92
 
93
- lambda {
93
+ expect {
94
94
  @scheduler.every '1s' do; end
95
- }.should raise_error(ArgumentError)
95
+ }.to raise_error(ArgumentError)
96
96
  end
97
97
  end
98
98
 
@@ -102,7 +102,7 @@ describe Rufus::Scheduler do
102
102
 
103
103
  job = @scheduler.schedule_every('1h') do; end
104
104
 
105
- job.frequency.should == 3600.0
105
+ expect(job.frequency).to eq(3600.0)
106
106
  end
107
107
  end
108
108
  end
@@ -24,8 +24,8 @@ describe Rufus::Scheduler do
24
24
  @scheduler.in(3600) do
25
25
  end
26
26
 
27
- @scheduler.jobs.size.should == 1
28
- @scheduler.jobs.first.class.should == Rufus::Scheduler::InJob
27
+ expect(@scheduler.jobs.size).to eq(1)
28
+ expect(@scheduler.jobs.first.class).to eq(Rufus::Scheduler::InJob)
29
29
  end
30
30
 
31
31
  it 'triggers a job' do
@@ -38,7 +38,7 @@ describe Rufus::Scheduler do
38
38
 
39
39
  sleep 0.9
40
40
 
41
- a.should == true
41
+ expect(a).to eq(true)
42
42
  end
43
43
 
44
44
  it 'removes the job after execution' do
@@ -48,7 +48,7 @@ describe Rufus::Scheduler do
48
48
 
49
49
  sleep 0.700
50
50
 
51
- @scheduler.jobs.size.should == 0
51
+ expect(@scheduler.jobs.size).to eq(0)
52
52
  end
53
53
  end
54
54
 
@@ -58,16 +58,16 @@ describe Rufus::Scheduler do
58
58
 
59
59
  job = @scheduler.schedule_in(3600) {}
60
60
 
61
- job.original.should == 3600
61
+ expect(job.original).to eq(3600)
62
62
  end
63
63
 
64
64
  it 'accepts a duration string' do
65
65
 
66
66
  job = @scheduler.schedule_in('1h') {}
67
67
 
68
- job.original.should == '1h'
69
- job.time.should >= job.scheduled_at + 3509
70
- job.time.should <= job.scheduled_at + 3601
68
+ expect(job.original).to eq('1h')
69
+ expect(job.time).to be >= job.scheduled_at + 3509
70
+ expect(job.time).to be <= job.scheduled_at + 3601
71
71
  end
72
72
 
73
73
  it 'accepts an ActiveSupport .from_now thinggy'