uv-rays 0.0.1 → 0.2.0

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.
@@ -1,19 +1,19 @@
1
1
  require 'uv-rays'
2
2
 
3
- describe UvRays::Scheduler::CronLine do
3
+ describe UV::Scheduler::CronLine do
4
4
 
5
5
  def cl(cronline_string)
6
- UvRays::Scheduler::CronLine.new(cronline_string)
6
+ UV::Scheduler::CronLine.new(cronline_string)
7
7
  end
8
8
 
9
9
  def match(line, time)
10
- cl(line).matches?(time).should == true
10
+ expect(cl(line).matches?(time)).to eq(true)
11
11
  end
12
12
  def no_match(line, time)
13
- cl(line).matches?(time).should == false
13
+ expect(cl(line).matches?(time)).to eq(false)
14
14
  end
15
15
  def to_a(line, array)
16
- cl(line).to_array.should == array
16
+ expect(cl(line).to_array).to eq(array)
17
17
  end
18
18
  def local(*args)
19
19
  Time.local(*args)
@@ -58,17 +58,17 @@ describe UvRays::Scheduler::CronLine do
58
58
 
59
59
  it 'rejects invalid weekday expressions' do
60
60
 
61
- lambda { cl '0 17 * * MON_FRI' }.should raise_error
61
+ expect { cl '0 17 * * MON_FRI' }.to raise_error
62
62
  # underline instead of dash
63
63
 
64
- lambda { cl '* * * * 9' }.should raise_error
65
- lambda { cl '* * * * 0-12' }.should raise_error
66
- lambda { cl '* * * * BLABLA' }.should raise_error
64
+ expect { cl '* * * * 9' }.to raise_error
65
+ expect { cl '* * * * 0-12' }.to raise_error
66
+ expect { cl '* * * * BLABLA' }.to raise_error
67
67
  end
68
68
 
69
69
  it 'rejects invalid cronlines' do
70
70
 
71
- lambda { cl '* nada * * 9' }.should raise_error(ArgumentError)
71
+ expect { cl '* nada * * 9' }.to raise_error(ArgumentError)
72
72
  end
73
73
 
74
74
  it 'interprets cron strings with TZ correctly' do
@@ -83,8 +83,8 @@ describe UvRays::Scheduler::CronLine do
83
83
  '* * * * * * America/New_York',
84
84
  [ nil, nil, nil, nil, nil, nil, nil, 'America/New_York' ])
85
85
 
86
- lambda { cl '* * * * * NotATimeZone' }.should raise_error
87
- lambda { cl '* * * * * * NotATimeZone' }.should raise_error
86
+ expect { cl '* * * * * NotATimeZone' }.to raise_error
87
+ expect { cl '* * * * * * NotATimeZone' }.to raise_error
88
88
  end
89
89
 
90
90
  it 'interprets cron strings with / (slashes) correctly' do
@@ -117,9 +117,9 @@ describe UvRays::Scheduler::CronLine do
117
117
 
118
118
  it 'does not support ranges for monthdays (sun#1-sun#2)' do
119
119
 
120
- lambda {
121
- UvRays::Scheduler::CronLine.new('* * * * sun#1-sun#2')
122
- }.should raise_error(ArgumentError)
120
+ expect {
121
+ UV::Scheduler::CronLine.new('* * * * sun#1-sun#2')
122
+ }.to raise_error(ArgumentError)
123
123
  end
124
124
 
125
125
  it 'accepts items with initial 0' do
@@ -142,27 +142,27 @@ describe UvRays::Scheduler::CronLine do
142
142
 
143
143
  it 'does not support ranges for L' do
144
144
 
145
- lambda { cl '* * 15-L * *'}.should raise_error(ArgumentError)
146
- lambda { cl '* * L/4 * *'}.should raise_error(ArgumentError)
145
+ expect { cl '* * 15-L * *'}.to raise_error(ArgumentError)
146
+ expect { cl '* * L/4 * *'}.to raise_error(ArgumentError)
147
147
  end
148
148
 
149
149
  it 'does not support multiple Ls' do
150
150
 
151
- lambda { cl '* * L,L * *'}.should raise_error(ArgumentError)
151
+ expect { cl '* * L,L * *'}.to raise_error(ArgumentError)
152
152
  end
153
153
 
154
154
  it 'raises if L is used for something else than days' do
155
155
 
156
- lambda { cl '* L * * *'}.should raise_error(ArgumentError)
156
+ expect { cl '* L * * *'}.to raise_error(ArgumentError)
157
157
  end
158
158
 
159
159
  it 'raises for out of range input' do
160
160
 
161
- lambda { cl '60-62 * * * *'}.should raise_error(ArgumentError)
162
- lambda { cl '62 * * * *'}.should raise_error(ArgumentError)
163
- lambda { cl '60 * * * *'}.should raise_error(ArgumentError)
164
- lambda { cl '* 25-26 * * *'}.should raise_error(ArgumentError)
165
- lambda { cl '* 25 * * *'}.should raise_error(ArgumentError)
161
+ expect { cl '60-62 * * * *'}.to raise_error(ArgumentError)
162
+ expect { cl '62 * * * *'}.to raise_error(ArgumentError)
163
+ expect { cl '60 * * * *'}.to raise_error(ArgumentError)
164
+ expect { cl '* 25-26 * * *'}.to raise_error(ArgumentError)
165
+ expect { cl '* 25 * * *'}.to raise_error(ArgumentError)
166
166
  #
167
167
  # as reported by Aimee Rose in
168
168
  # https://github.com/jmettraux/rufus-scheduler/pull/58
@@ -172,66 +172,66 @@ describe UvRays::Scheduler::CronLine do
172
172
  describe '#next_time' do
173
173
 
174
174
  def nt(cronline, now)
175
- UvRays::Scheduler::CronLine.new(cronline).next_time(now)
175
+ UV::Scheduler::CronLine.new(cronline).next_time(now)
176
176
  end
177
177
 
178
178
  it 'computes the next occurence correctly' do
179
179
 
180
180
  now = Time.at(0).getutc # Thu Jan 01 00:00:00 UTC 1970
181
181
 
182
- nt('* * * * *', now).should == now + 60
183
- nt('* * * * sun', now).should == now + 259200
184
- nt('* * * * * *', now).should == now + 1
185
- nt('* * 13 * fri', now).should == now + 3715200
182
+ expect(nt('* * * * *', now)).to eq(now + 60)
183
+ expect(nt('* * * * sun', now)).to eq(now + 259200)
184
+ expect(nt('* * * * * *', now)).to eq(now + 1)
185
+ expect(nt('* * 13 * fri', now)).to eq(now + 3715200)
186
186
 
187
- nt('10 12 13 12 *', now).should == now + 29938200
187
+ expect(nt('10 12 13 12 *', now)).to eq(now + 29938200)
188
188
  # this one is slow (1 year == 3 seconds)
189
189
  #
190
190
  # historical note:
191
191
  # (comment made in 2006 or 2007, the underlying libs got better and
192
192
  # that slowness is gone)
193
193
 
194
- nt('0 0 * * thu', now).should == now + 604800
195
- nt('00 0 * * thu', now).should == now + 604800
194
+ expect(nt('0 0 * * thu', now)).to eq(now + 604800)
195
+ expect(nt('00 0 * * thu', now)).to eq(now + 604800)
196
196
 
197
- nt('0 0 * * *', now).should == now + 24 * 3600
198
- nt('0 24 * * *', now).should == now + 24 * 3600
197
+ expect(nt('0 0 * * *', now)).to eq(now + 24 * 3600)
198
+ expect(nt('0 24 * * *', now)).to eq(now + 24 * 3600)
199
199
 
200
200
  now = local(2008, 12, 31, 23, 59, 59, 0)
201
201
 
202
- nt('* * * * *', now).should == now + 1
202
+ expect(nt('* * * * *', now)).to eq(now + 1)
203
203
  end
204
204
 
205
205
  it 'computes the next occurence correctly in UTC (TZ not specified)' do
206
206
 
207
207
  now = utc(1970, 1, 1)
208
208
 
209
- nt('* * * * *', now).should == utc(1970, 1, 1, 0, 1)
210
- nt('* * * * sun', now).should == utc(1970, 1, 4)
211
- nt('* * * * * *', now).should == utc(1970, 1, 1, 0, 0, 1)
212
- nt('* * 13 * fri', now).should == utc(1970, 2, 13)
209
+ expect(nt('* * * * *', now)).to eq(utc(1970, 1, 1, 0, 1))
210
+ expect(nt('* * * * sun', now)).to eq(utc(1970, 1, 4))
211
+ expect(nt('* * * * * *', now)).to eq(utc(1970, 1, 1, 0, 0, 1))
212
+ expect(nt('* * 13 * fri', now)).to eq(utc(1970, 2, 13))
213
213
 
214
- nt('10 12 13 12 *', now).should == utc(1970, 12, 13, 12, 10)
214
+ expect(nt('10 12 13 12 *', now)).to eq(utc(1970, 12, 13, 12, 10))
215
215
  # this one is slow (1 year == 3 seconds)
216
- nt('* * 1 6 *', now).should == utc(1970, 6, 1)
216
+ expect(nt('* * 1 6 *', now)).to eq(utc(1970, 6, 1))
217
217
 
218
- nt('0 0 * * thu', now).should == utc(1970, 1, 8)
218
+ expect(nt('0 0 * * thu', now)).to eq(utc(1970, 1, 8))
219
219
  end
220
220
 
221
221
  it 'computes the next occurence correctly in local TZ (TZ not specified)' do
222
222
 
223
223
  now = local(1970, 1, 1)
224
224
 
225
- nt('* * * * *', now).should == local(1970, 1, 1, 0, 1)
226
- nt('* * * * sun', now).should == local(1970, 1, 4)
227
- nt('* * * * * *', now).should == local(1970, 1, 1, 0, 0, 1)
228
- nt('* * 13 * fri', now).should == local(1970, 2, 13)
225
+ expect(nt('* * * * *', now)).to eq(local(1970, 1, 1, 0, 1))
226
+ expect(nt('* * * * sun', now)).to eq(local(1970, 1, 4))
227
+ expect(nt('* * * * * *', now)).to eq(local(1970, 1, 1, 0, 0, 1))
228
+ expect(nt('* * 13 * fri', now)).to eq(local(1970, 2, 13))
229
229
 
230
- nt('10 12 13 12 *', now).should == local(1970, 12, 13, 12, 10)
230
+ expect(nt('10 12 13 12 *', now)).to eq(local(1970, 12, 13, 12, 10))
231
231
  # this one is slow (1 year == 3 seconds)
232
- nt('* * 1 6 *', now).should == local(1970, 6, 1)
232
+ expect(nt('* * 1 6 *', now)).to eq(local(1970, 6, 1))
233
233
 
234
- nt('0 0 * * thu', now).should == local(1970, 1, 8)
234
+ expect(nt('0 0 * * thu', now)).to eq(local(1970, 1, 8))
235
235
  end
236
236
 
237
237
  it 'computes the next occurence correctly in UTC (TZ specified)' do
@@ -241,15 +241,15 @@ describe UvRays::Scheduler::CronLine do
241
241
  now = tz.local_to_utc(local(1970, 1, 1))
242
242
  # Midnight in zone, UTC
243
243
 
244
- nt("* * * * * #{zone}", now).should == utc(1969, 12, 31, 23, 1)
245
- nt("* * * * sun #{zone}", now).should == utc(1970, 1, 3, 23)
246
- nt("* * * * * * #{zone}", now).should == utc(1969, 12, 31, 23, 0, 1)
247
- nt("* * 13 * fri #{zone}", now).should == utc(1970, 2, 12, 23)
244
+ expect(nt("* * * * * #{zone}", now)).to eq(utc(1969, 12, 31, 23, 1))
245
+ expect(nt("* * * * sun #{zone}", now)).to eq(utc(1970, 1, 3, 23))
246
+ expect(nt("* * * * * * #{zone}", now)).to eq(utc(1969, 12, 31, 23, 0, 1))
247
+ expect(nt("* * 13 * fri #{zone}", now)).to eq(utc(1970, 2, 12, 23))
248
248
 
249
- nt("10 12 13 12 * #{zone}", now).should == utc(1970, 12, 13, 11, 10)
250
- nt("* * 1 6 * #{zone}", now).should == utc(1970, 5, 31, 23)
249
+ expect(nt("10 12 13 12 * #{zone}", now)).to eq(utc(1970, 12, 13, 11, 10))
250
+ expect(nt("* * 1 6 * #{zone}", now)).to eq(utc(1970, 5, 31, 23))
251
251
 
252
- nt("0 0 * * thu #{zone}", now).should == utc(1970, 1, 7, 23)
252
+ expect(nt("0 0 * * thu #{zone}", now)).to eq(utc(1970, 1, 7, 23))
253
253
  end
254
254
 
255
255
  #it 'computes the next occurence correctly in local TZ (TZ specified)' do
@@ -257,72 +257,72 @@ describe UvRays::Scheduler::CronLine do
257
257
  # tz = TZInfo::Timezone.get(zone)
258
258
  # now = tz.local_to_utc(utc(1970, 1, 1)).localtime
259
259
  # # Midnight in zone, local time
260
- # nt("* * * * * #{zone}", now).should == local(1969, 12, 31, 18, 1)
261
- # nt("* * * * sun #{zone}", now).should == local(1970, 1, 3, 18)
262
- # nt("* * * * * * #{zone}", now).should == local(1969, 12, 31, 18, 0, 1)
263
- # nt("* * 13 * fri #{zone}", now).should == local(1970, 2, 12, 18)
264
- # nt("10 12 13 12 * #{zone}", now).should == local(1970, 12, 13, 6, 10)
265
- # nt("* * 1 6 * #{zone}", now).should == local(1970, 5, 31, 19)
266
- # nt("0 0 * * thu #{zone}", now).should == local(1970, 1, 7, 18)
260
+ # expect(nt("* * * * * #{zone}", now)).to eq(local(1969, 12, 31, 18, 1))
261
+ # expect(nt("* * * * sun #{zone}", now)).to eq(local(1970, 1, 3, 18))
262
+ # expect(nt("* * * * * * #{zone}", now)).to eq(local(1969, 12, 31, 18, 0, 1))
263
+ # expect(nt("* * 13 * fri #{zone}", now)).to eq(local(1970, 2, 12, 18))
264
+ # expect(nt("10 12 13 12 * #{zone}", now)).to eq(local(1970, 12, 13, 6, 10))
265
+ # expect(nt("* * 1 6 * #{zone}", now)).to eq(local(1970, 5, 31, 19))
266
+ # expect(nt("0 0 * * thu #{zone}", now)).to eq(local(1970, 1, 7, 18))
267
267
  #end
268
268
 
269
269
  it 'computes the next time correctly when there is a sun#2 involved' do
270
270
 
271
- nt('* * * * sun#1', local(1970, 1, 1)).should == local(1970, 1, 4)
272
- nt('* * * * sun#2', local(1970, 1, 1)).should == local(1970, 1, 11)
271
+ expect(nt('* * * * sun#1', local(1970, 1, 1))).to eq(local(1970, 1, 4))
272
+ expect(nt('* * * * sun#2', local(1970, 1, 1))).to eq(local(1970, 1, 11))
273
273
 
274
- nt('* * * * sun#2', local(1970, 1, 12)).should == local(1970, 2, 8)
274
+ expect(nt('* * * * sun#2', local(1970, 1, 12))).to eq(local(1970, 2, 8))
275
275
  end
276
276
 
277
277
  it 'computes the next time correctly when there is a sun#2,sun#3 involved' do
278
278
 
279
- nt('* * * * sun#2,sun#3', local(1970, 1, 1)).should == local(1970, 1, 11)
280
- nt('* * * * sun#2,sun#3', local(1970, 1, 12)).should == local(1970, 1, 18)
279
+ expect(nt('* * * * sun#2,sun#3', local(1970, 1, 1))).to eq(local(1970, 1, 11))
280
+ expect(nt('* * * * sun#2,sun#3', local(1970, 1, 12))).to eq(local(1970, 1, 18))
281
281
  end
282
282
 
283
283
  it 'understands sun#L' do
284
284
 
285
- nt('* * * * sun#L', local(1970, 1, 1)).should == local(1970, 1, 25)
285
+ expect(nt('* * * * sun#L', local(1970, 1, 1))).to eq(local(1970, 1, 25))
286
286
  end
287
287
 
288
288
  it 'understands sun#-1' do
289
289
 
290
- nt('* * * * sun#-1', local(1970, 1, 1)).should == local(1970, 1, 25)
290
+ expect(nt('* * * * sun#-1', local(1970, 1, 1))).to eq(local(1970, 1, 25))
291
291
  end
292
292
 
293
293
  it 'understands sun#-2' do
294
294
 
295
- nt('* * * * sun#-2', local(1970, 1, 1)).should == local(1970, 1, 18)
295
+ expect(nt('* * * * sun#-2', local(1970, 1, 1))).to eq(local(1970, 1, 18))
296
296
  end
297
297
 
298
298
  it 'computes the next time correctly when "L" (last day of month)' do
299
299
 
300
- nt('* * L * *', lo(1970, 1, 1)).should == lo(1970, 1, 31)
301
- nt('* * L * *', lo(1970, 2, 1)).should == lo(1970, 2, 28)
302
- nt('* * L * *', lo(1972, 2, 1)).should == lo(1972, 2, 29)
303
- nt('* * L * *', lo(1970, 4, 1)).should == lo(1970, 4, 30)
300
+ expect(nt('* * L * *', lo(1970, 1, 1))).to eq(lo(1970, 1, 31))
301
+ expect(nt('* * L * *', lo(1970, 2, 1))).to eq(lo(1970, 2, 28))
302
+ expect(nt('* * L * *', lo(1972, 2, 1))).to eq(lo(1972, 2, 29))
303
+ expect(nt('* * L * *', lo(1970, 4, 1))).to eq(lo(1970, 4, 30))
304
304
  end
305
305
 
306
306
  it 'returns a time with subseconds chopped off' do
307
307
 
308
- nt('* * * * *', Time.now).usec.should == 0
309
- nt('* * * * *', Time.now).iso8601(10).match(/\.0+[^\d]/).should_not == nil
308
+ expect(nt('* * * * *', Time.now).usec).to eq(0)
309
+ expect(nt('* * * * *', Time.now).iso8601(10).match(/\.0+[^\d]/)).not_to eq(nil)
310
310
  end
311
311
  end
312
312
 
313
313
  describe '#previous_time' do
314
314
 
315
315
  def pt(cronline, now)
316
- UvRays::Scheduler::CronLine.new(cronline).previous_time(now)
316
+ UV::Scheduler::CronLine.new(cronline).previous_time(now)
317
317
  end
318
318
 
319
319
  it 'returns the previous time the cron should have triggered' do
320
320
 
321
- pt('* * * * sun', lo(1970, 1, 1)).should == lo(1969, 12, 28, 23, 59, 00)
322
- pt('* * 13 * *', lo(1970, 1, 1)).should == lo(1969, 12, 13, 23, 59, 00)
323
- pt('0 12 13 * *', lo(1970, 1, 1)).should == lo(1969, 12, 13, 12, 00)
321
+ expect(pt('* * * * sun', lo(1970, 1, 1))).to eq(lo(1969, 12, 28, 23, 59, 00))
322
+ expect(pt('* * 13 * *', lo(1970, 1, 1))).to eq(lo(1969, 12, 13, 23, 59, 00))
323
+ expect(pt('0 12 13 * *', lo(1970, 1, 1))).to eq(lo(1969, 12, 13, 12, 00))
324
324
 
325
- pt('* * * * * sun', lo(1970, 1, 1)).should == lo(1969, 12, 28, 23, 59, 59)
325
+ expect(pt('* * * * * sun', lo(1970, 1, 1))).to eq(lo(1969, 12, 28, 23, 59, 59))
326
326
  end
327
327
  end
328
328
 
@@ -400,17 +400,17 @@ describe UvRays::Scheduler::CronLine do
400
400
 
401
401
  it 'returns the appropriate "sun#2"-like string' do
402
402
 
403
- class UvRays::Scheduler::CronLine
403
+ class UV::Scheduler::CronLine
404
404
  public :monthdays
405
405
  end
406
406
 
407
- cl = UvRays::Scheduler::CronLine.new('* * * * *')
407
+ cl = UV::Scheduler::CronLine.new('* * * * *')
408
408
 
409
- cl.monthdays(local(1970, 1, 1)).should == %w[ thu#1 thu#-5 ]
410
- cl.monthdays(local(1970, 1, 7)).should == %w[ wed#1 wed#-4 ]
411
- cl.monthdays(local(1970, 1, 14)).should == %w[ wed#2 wed#-3 ]
409
+ expect(cl.monthdays(local(1970, 1, 1))).to eq(%w[ thu#1 thu#-5 ])
410
+ expect(cl.monthdays(local(1970, 1, 7))).to eq(%w[ wed#1 wed#-4 ])
411
+ expect(cl.monthdays(local(1970, 1, 14))).to eq(%w[ wed#2 wed#-3 ])
412
412
 
413
- cl.monthdays(local(2011, 3, 11)).should == %w[ fri#2 fri#-3 ]
413
+ expect(cl.monthdays(local(2011, 3, 11))).to eq(%w[ fri#2 fri#-3 ])
414
414
  end
415
415
  end
416
416
 
@@ -418,12 +418,12 @@ describe UvRays::Scheduler::CronLine do
418
418
 
419
419
  it 'returns the shortest delta between two occurrences' do
420
420
 
421
- UvRays::Scheduler::CronLine.new('* * * * *').frequency.should == 60
422
- UvRays::Scheduler::CronLine.new('* * * * * *').frequency.should == 1
421
+ expect(UV::Scheduler::CronLine.new('* * * * *').frequency).to eq(60)
422
+ expect(UV::Scheduler::CronLine.new('* * * * * *').frequency).to eq(1)
423
423
 
424
- UvRays::Scheduler::CronLine.new('5 23 * * *').frequency.should == 24 * 3600
425
- UvRays::Scheduler::CronLine.new('5 * * * *').frequency.should == 3600
426
- UvRays::Scheduler::CronLine.new('10,20,30 * * * *').frequency.should == 600
424
+ expect(UV::Scheduler::CronLine.new('5 23 * * *').frequency).to eq(24 * 3600)
425
+ expect(UV::Scheduler::CronLine.new('5 * * * *').frequency).to eq(3600)
426
+ expect(UV::Scheduler::CronLine.new('10,20,30 * * * *').frequency).to eq(600)
427
427
  end
428
428
  end
429
429
  end
@@ -1,6 +1,6 @@
1
1
  require 'uv-rays'
2
2
 
3
- describe UvRays::Scheduler do
3
+ describe UV::Scheduler do
4
4
  before :each do
5
5
  @loop = Libuv::Loop.new
6
6
  @general_failure = []
@@ -29,10 +29,10 @@ describe UvRays::Scheduler do
29
29
  end
30
30
  }
31
31
 
32
- @general_failure.should == []
33
- @event.should == @result
32
+ expect(@general_failure).to eq([])
33
+ expect(@event).to eq(@result)
34
34
  @diff = @triggered_at - @event.last_scheduled
35
- (@diff >= 500 && @diff < 750).should == true
35
+ expect((@diff >= 500 && @diff < 750)).to eq(true)
36
36
  end
37
37
 
38
38
  it "should be able to schedule a one shot event using 'at'" do
@@ -52,10 +52,10 @@ describe UvRays::Scheduler do
52
52
  end
53
53
  }
54
54
 
55
- @general_failure.should == []
56
- @event.should == @result
55
+ expect(@general_failure).to eq([])
56
+ expect(@event).to eq(@result)
57
57
  @diff = @triggered_at - @event.last_scheduled
58
- (@diff >= 1000 && @diff < 1250).should == true
58
+ expect((@diff >= 1000 && @diff < 1250)).to eq(true)
59
59
  end
60
60
 
61
61
  it "should be able to schedule a repeat event" do
@@ -81,10 +81,10 @@ describe UvRays::Scheduler do
81
81
  end
82
82
  }
83
83
 
84
- @general_failure.should == []
85
- @run.should == 2
86
- @event.should == @result
84
+ expect(@general_failure).to eq([])
85
+ expect(@run).to eq(2)
86
+ expect(@event).to eq(@result)
87
87
  @diff = @triggered_at - @event.last_scheduled
88
- (@diff >= 250 && @diff < 500).should == true
88
+ expect((@diff >= 250 && @diff < 500)).to eq(true)
89
89
  end
90
90
  end
@@ -7,126 +7,126 @@
7
7
 
8
8
 
9
9
 
10
- describe UvRays::Scheduler do
10
+ describe UV::Scheduler do
11
11
 
12
12
  describe '.parse_duration' do
13
13
 
14
14
  def pd(s)
15
- UvRays::Scheduler.parse_duration(s)
15
+ UV::Scheduler.parse_duration(s)
16
16
  end
17
17
 
18
18
  it 'parses duration strings' do
19
19
 
20
- pd('-1.0d1.0w1.0d').should == -777600000
21
- pd('-1d1w1d').should == -777600000
22
- pd('-1w2d').should == -777600000
23
- pd('-1h10s').should == -3610000
24
- pd('-1h').should == -3600000
25
- pd('-5.').should == -5
26
- pd('-2.5s').should == -2500
27
- pd('-1s').should == -1000
28
- pd('-500').should == -500
29
- pd('').should == 0
30
- pd('5.0').should == 5
31
- pd('0.5').should == 0
32
- pd('.5').should == 0
33
- pd('5.').should == 5
34
- pd('500').should == 500
35
- pd('1000').should == 1000
36
- pd('1').should == 1
37
- pd('1s').should == 1000
38
- pd('2.5s').should == 2500
39
- pd('1h').should == 3600000
40
- pd('1h10s').should == 3610000
41
- pd('1w2d').should == 777600000
42
- pd('1d1w1d').should == 777600000
43
- pd('1.0d1.0w1.0d').should == 777600000
44
-
45
- pd('.5m').should == 30000
46
- pd('5.m').should == 300000
47
- pd('1m.5s').should == 60500
48
- pd('-.5m').should == -30000
49
-
50
- pd('1').should == 1
51
- pd('0.1').should == 0
52
- pd('1s').should == 1000
20
+ expect(pd('-1.0d1.0w1.0d')).to eq(-777600000)
21
+ expect(pd('-1d1w1d')).to eq(-777600000)
22
+ expect(pd('-1w2d')).to eq(-777600000)
23
+ expect(pd('-1h10s')).to eq(-3610000)
24
+ expect(pd('-1h')).to eq(-3600000)
25
+ expect(pd('-5.')).to eq(-5)
26
+ expect(pd('-2.5s')).to eq(-2500)
27
+ expect(pd('-1s')).to eq(-1000)
28
+ expect(pd('-500')).to eq(-500)
29
+ expect(pd('')).to eq(0)
30
+ expect(pd('5.0')).to eq(5)
31
+ expect(pd('0.5')).to eq(0)
32
+ expect(pd('.5')).to eq(0)
33
+ expect(pd('5.')).to eq(5)
34
+ expect(pd('500')).to eq(500)
35
+ expect(pd('1000')).to eq(1000)
36
+ expect(pd('1')).to eq(1)
37
+ expect(pd('1s')).to eq(1000)
38
+ expect(pd('2.5s')).to eq(2500)
39
+ expect(pd('1h')).to eq(3600000)
40
+ expect(pd('1h10s')).to eq(3610000)
41
+ expect(pd('1w2d')).to eq(777600000)
42
+ expect(pd('1d1w1d')).to eq(777600000)
43
+ expect(pd('1.0d1.0w1.0d')).to eq(777600000)
44
+
45
+ expect(pd('.5m')).to eq(30000)
46
+ expect(pd('5.m')).to eq(300000)
47
+ expect(pd('1m.5s')).to eq(60500)
48
+ expect(pd('-.5m')).to eq(-30000)
49
+
50
+ expect(pd('1')).to eq(1)
51
+ expect(pd('0.1')).to eq(0)
52
+ expect(pd('1s')).to eq(1000)
53
53
  end
54
54
 
55
55
  it 'calls #to_s on its input' do
56
56
 
57
- pd(1).should == 1
57
+ expect(pd(1)).to eq(1)
58
58
  end
59
59
 
60
60
  it 'raises on wrong duration strings' do
61
61
 
62
- lambda { pd('-') }.should raise_error(ArgumentError)
63
- lambda { pd('h') }.should raise_error(ArgumentError)
64
- lambda { pd('whatever') }.should raise_error(ArgumentError)
65
- lambda { pd('hms') }.should raise_error(ArgumentError)
62
+ expect { pd('-') }.to raise_error(ArgumentError)
63
+ expect { pd('h') }.to raise_error(ArgumentError)
64
+ expect { pd('whatever') }.to raise_error(ArgumentError)
65
+ expect { pd('hms') }.to raise_error(ArgumentError)
66
66
 
67
- lambda { pd(' 1h ') }.should raise_error(ArgumentError)
67
+ expect { pd(' 1h ') }.to raise_error(ArgumentError)
68
68
  end
69
69
  end
70
70
 
71
71
  describe '.to_duration' do
72
72
 
73
73
  def td(o, opts={})
74
- UvRays::Scheduler.to_duration(o, opts)
74
+ UV::Scheduler.to_duration(o, opts)
75
75
  end
76
76
 
77
77
  it 'turns integers into duration strings' do
78
78
 
79
- td(0).should == '0s'
80
- td(60000).should == '1m'
81
- td(61000).should == '1m1s'
82
- td(3661000).should == '1h1m1s'
83
- td(24 * 3600 * 1000).should == '1d'
84
- td(7 * 24 * 3600 * 1000 + 1000).should == '1w1s'
85
- td(30 * 24 * 3600 * 1000 + 1000).should == '4w2d1s'
79
+ expect(td(0)).to eq('0s')
80
+ expect(td(60000)).to eq('1m')
81
+ expect(td(61000)).to eq('1m1s')
82
+ expect(td(3661000)).to eq('1h1m1s')
83
+ expect(td(24 * 3600 * 1000)).to eq('1d')
84
+ expect(td(7 * 24 * 3600 * 1000 + 1000)).to eq('1w1s')
85
+ expect(td(30 * 24 * 3600 * 1000 + 1000)).to eq('4w2d1s')
86
86
  end
87
87
 
88
88
  it 'ignores seconds and milliseconds if :drop_seconds => true' do
89
89
 
90
- td(0, :drop_seconds => true).should == '0m'
91
- td(5000, :drop_seconds => true).should == '0m'
92
- td(61000, :drop_seconds => true).should == '1m'
90
+ expect(td(0, :drop_seconds => true)).to eq('0m')
91
+ expect(td(5000, :drop_seconds => true)).to eq('0m')
92
+ expect(td(61000, :drop_seconds => true)).to eq('1m')
93
93
  end
94
94
 
95
95
  it 'displays months if :months => true' do
96
96
 
97
- td(1000, :months => true).should == '1s'
98
- td(30 * 24 * 3600 * 1000 + 1000, :months => true).should == '1M1s'
97
+ expect(td(1000, :months => true)).to eq('1s')
98
+ expect(td(30 * 24 * 3600 * 1000 + 1000, :months => true)).to eq('1M1s')
99
99
  end
100
100
 
101
101
  it 'turns floats into duration strings' do
102
102
 
103
- td(100).should == '100'
104
- td(1100).should == '1s100'
103
+ expect(td(100)).to eq('100')
104
+ expect(td(1100)).to eq('1s100')
105
105
  end
106
106
  end
107
107
 
108
108
  describe '.to_duration_hash' do
109
109
 
110
110
  def tdh(o, opts={})
111
- UvRays::Scheduler.to_duration_hash(o, opts)
111
+ UV::Scheduler.to_duration_hash(o, opts)
112
112
  end
113
113
 
114
114
  it 'turns integers duration hashes' do
115
115
 
116
- tdh(0).should == {}
117
- tdh(60000).should == { :m => 1 }
116
+ expect(tdh(0)).to eq({})
117
+ expect(tdh(60000)).to eq({ :m => 1 })
118
118
  end
119
119
 
120
120
  it 'turns floats duration hashes' do
121
121
 
122
- tdh(128).should == { :ms => 128 }
123
- tdh(60127).should == { :m => 1, :ms => 127 }
122
+ expect(tdh(128)).to eq({ :ms => 128 })
123
+ expect(tdh(60127)).to eq({ :m => 1, :ms => 127 })
124
124
  end
125
125
 
126
126
  it 'drops seconds and milliseconds if :drop_seconds => true' do
127
127
 
128
- tdh(61127).should == { :m => 1, :s => 1, :ms => 127 }
129
- tdh(61127, :drop_seconds => true).should == { :m => 1 }
128
+ expect(tdh(61127)).to eq({ :m => 1, :s => 1, :ms => 127 })
129
+ expect(tdh(61127, :drop_seconds => true)).to eq({ :m => 1 })
130
130
  end
131
131
  end
132
132
  end
data/uv-rays.gemspec CHANGED
@@ -2,7 +2,7 @@ require File.expand_path("../lib/uv-rays/version", __FILE__)
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "uv-rays"
5
- gem.version = UvRays::VERSION
5
+ gem.version = UV::VERSION
6
6
  gem.license = 'MIT'
7
7
  gem.authors = ["Stephen von Takach"]
8
8
  gem.email = ["steve@cotag.me"]
@@ -13,13 +13,13 @@ Gem::Specification.new do |gem|
13
13
  gem.required_ruby_version = '>= 1.9.2'
14
14
  gem.require_paths = ["lib"]
15
15
 
16
- gem.add_runtime_dependency 'libuv'
16
+ gem.add_runtime_dependency 'libuv', '>= 0.11.19'
17
17
  gem.add_runtime_dependency 'bisect'
18
18
  gem.add_runtime_dependency 'tzinfo'
19
19
  gem.add_runtime_dependency 'cookiejar'
20
20
  gem.add_runtime_dependency 'ipaddress'
21
21
  gem.add_runtime_dependency 'addressable'
22
- gem.add_runtime_dependency 'http-parser'
22
+ gem.add_runtime_dependency 'http-parser', '>= 1.0.4'
23
23
 
24
24
  gem.add_development_dependency 'rspec', '>= 2.14'
25
25
  gem.add_development_dependency 'rake', '>= 10.1'