rufus-scheduler 2.0.6 → 2.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,19 +5,19 @@
5
5
  # Mon May 4 17:07:17 JST 2009
6
6
  #
7
7
 
8
- require File.dirname(__FILE__) + '/spec_base'
8
+ require File.join(File.dirname(__FILE__), '/spec_base')
9
9
 
10
10
 
11
11
  describe SCHEDULER_CLASS do
12
12
 
13
- before do
13
+ before(:each) do
14
14
  @s = start_scheduler
15
15
  end
16
- after do
16
+ after(:each) do
17
17
  stop_scheduler(@s)
18
18
  end
19
19
 
20
- it 'should emit exception messages to stdout' do
20
+ it 'emits exception messages to stdout' do
21
21
 
22
22
  require 'stringio' unless defined?(StringIO) # ruby 1.9
23
23
 
@@ -34,14 +34,14 @@ describe SCHEDULER_CLASS do
34
34
  $stdout = stdout
35
35
  s.close
36
36
 
37
- s.string.should.match(/Houston we have a problem/)
37
+ s.string.should match(/Houston we have a problem/)
38
38
  end
39
39
 
40
- it 'should accept custom handling of exceptions' do
40
+ it 'accepts custom handling of exceptions' do
41
41
 
42
42
  $job = nil
43
43
 
44
- def @s.handle_exception (j, e)
44
+ def @s.handle_exception(j, e)
45
45
  $job = j
46
46
  end
47
47
 
@@ -52,14 +52,14 @@ describe SCHEDULER_CLASS do
52
52
  sleep 0.500
53
53
  sleep 0.500
54
54
 
55
- $job.class.should.equal(Rufus::Scheduler::InJob)
55
+ $job.class.should == Rufus::Scheduler::InJob
56
56
  end
57
57
 
58
- it 'should accept overriding #log_exception' do
58
+ it 'accepts overriding #log_exception' do
59
59
 
60
60
  $e = nil
61
61
 
62
- def @s.log_exception (e)
62
+ def @s.log_exception(e)
63
63
  $e = e
64
64
  end
65
65
 
@@ -70,8 +70,7 @@ describe SCHEDULER_CLASS do
70
70
  sleep 0.500
71
71
  sleep 0.500
72
72
 
73
- $e.to_s.should.equal('Houston we have a problem')
73
+ $e.to_s.should == 'Houston we have a problem'
74
74
  end
75
-
76
75
  end
77
76
 
@@ -5,37 +5,37 @@
5
5
  # Sat Mar 21 17:36:36 JST 2009
6
6
  #
7
7
 
8
- require File.dirname(__FILE__) + '/spec_base'
8
+ require File.join(File.dirname(__FILE__), 'spec_base')
9
9
 
10
10
 
11
11
  describe "#{SCHEDULER_CLASS}#in" do
12
12
 
13
- before do
13
+ before(:each) do
14
14
  @s = start_scheduler
15
15
  end
16
- after do
16
+ after(:each) do
17
17
  stop_scheduler(@s)
18
18
  end
19
19
 
20
- it 'should have job ids with the class name in it' do
20
+ it 'has job ids with the class name in it' do
21
21
 
22
22
  j0 = @s.in(1) {}
23
- j0.job_id.should.match(/Rufus::Scheduler::InJob/)
23
+ j0.job_id.should match(/Rufus::Scheduler::InJob/)
24
24
  end
25
25
 
26
- it 'should track scheduled in jobs' do
26
+ it 'tracks scheduled in jobs' do
27
27
 
28
28
  @s.in(1) {}
29
29
 
30
30
  wait_next_tick
31
- @s.jobs.size.should.equal(1)
31
+ @s.jobs.size.should == 1
32
32
 
33
33
  sleep 1.5
34
34
 
35
- @s.jobs.size.should.equal(0)
35
+ @s.jobs.size.should == 0
36
36
  end
37
37
 
38
- it 'should schedule in 1' do
38
+ it 'schedules in 1' do
39
39
 
40
40
  var = nil
41
41
 
@@ -43,13 +43,13 @@ describe "#{SCHEDULER_CLASS}#in" do
43
43
  var = true
44
44
  end
45
45
 
46
- var.should.be.nil
46
+ var.should == nil
47
47
  sleep 1.5
48
48
 
49
- var.should.be.true
49
+ var.should == true
50
50
  end
51
51
 
52
- it 'should schedule in 1.0' do
52
+ it 'schedules in 1.0' do
53
53
 
54
54
  var = nil
55
55
 
@@ -57,13 +57,13 @@ describe "#{SCHEDULER_CLASS}#in" do
57
57
  var = true
58
58
  end
59
59
 
60
- var.should.be.nil
60
+ var.should == nil
61
61
  sleep 1.5
62
62
 
63
- var.should.be.true
63
+ var.should == true
64
64
  end
65
65
 
66
- it 'should schedule in 1s' do
66
+ it 'schedules in 1s' do
67
67
 
68
68
  var = nil
69
69
 
@@ -71,13 +71,13 @@ describe "#{SCHEDULER_CLASS}#in" do
71
71
  var = true
72
72
  end
73
73
 
74
- var.should.be.nil
74
+ var.should == nil
75
75
  sleep 1.5
76
76
 
77
- var.should.be.true
77
+ var.should == true
78
78
  end
79
79
 
80
- it 'should trigger [almost] immediately jobs in the past' do
80
+ it 'triggers [almost] immediately jobs in the past' do
81
81
 
82
82
  var = nil
83
83
 
@@ -88,11 +88,11 @@ describe "#{SCHEDULER_CLASS}#in" do
88
88
  #wait_next_tick
89
89
  sleep 0.550
90
90
 
91
- var.should.be.true
92
- @s.jobs.should.be.empty
91
+ var.should == true
92
+ @s.jobs.should == {}
93
93
  end
94
94
 
95
- it 'should not trigger jobs in the past when :discard_past => true' do
95
+ it 'does not trigger jobs in the past when :discard_past => true' do
96
96
 
97
97
  var = nil
98
98
 
@@ -100,47 +100,46 @@ describe "#{SCHEDULER_CLASS}#in" do
100
100
  var = true
101
101
  end
102
102
 
103
- var.should.be.nil
104
- @s.jobs.should.be.empty
103
+ var.should == nil
104
+ @s.jobs.should == {}
105
105
  end
106
106
 
107
- it 'should unschedule job' do
107
+ it 'unschedules jobs' do
108
108
 
109
109
  job = @s.in '2d' do
110
110
  end
111
111
 
112
112
  wait_next_tick
113
113
 
114
- @s.jobs.size.should.equal(1)
114
+ @s.jobs.size.should == 1
115
115
 
116
116
  @s.unschedule(job.job_id)
117
117
 
118
- @s.jobs.size.should.equal(0)
118
+ @s.jobs.size.should == 0
119
119
  end
120
120
 
121
- it 'should accept tags for jobs' do
121
+ it 'accepts tags for jobs' do
122
122
 
123
123
  job = @s.in '2d', :tags => 'spec' do
124
124
  end
125
125
 
126
126
  wait_next_tick
127
127
 
128
- @s.find_by_tag('spec').size.should.equal(1)
129
- @s.find_by_tag('spec').first.job_id.should.equal(job.job_id)
128
+ @s.find_by_tag('spec').size.should == 1
129
+ @s.find_by_tag('spec').first.job_id.should == job.job_id
130
130
  end
131
-
132
131
  end
133
132
 
134
133
  describe Rufus::Scheduler::InJob do
135
134
 
136
- before do
135
+ before(:each) do
137
136
  @s = start_scheduler
138
137
  end
139
- after do
138
+ after(:each) do
140
139
  stop_scheduler(@s)
141
140
  end
142
141
 
143
- it 'should unschedule itself' do
142
+ it 'unschedules itself' do
144
143
 
145
144
  job = @s.in '2d' do
146
145
  end
@@ -149,17 +148,17 @@ describe Rufus::Scheduler::InJob do
149
148
 
150
149
  job.unschedule
151
150
 
152
- @s.jobs.size.should.equal(0)
151
+ @s.jobs.size.should == 0
153
152
  end
154
153
 
155
- it 'should respond to #next_time' do
154
+ it 'responds to #next_time' do
156
155
 
157
156
  t = Time.now + 3 * 3600
158
157
 
159
158
  job = @s.in '3h' do
160
159
  end
161
160
 
162
- job.next_time.to_i.should.equal(t.to_i)
161
+ job.next_time.to_i.should == t.to_i
163
162
  end
164
163
  end
165
164
 
@@ -5,89 +5,89 @@
5
5
  # Fri Mar 20 23:46:32 JST 2009
6
6
  #
7
7
 
8
- require File.dirname(__FILE__) + '/spec_base'
8
+ require File.join(File.dirname(__FILE__), 'spec_base')
9
9
 
10
10
 
11
11
  describe 'rufus/otime' do
12
12
 
13
- def pts (s)
13
+ def pts(s)
14
14
  Rufus.parse_time_string(s)
15
15
  end
16
16
 
17
- def tts (f, opts={})
17
+ def tts(f, opts={})
18
18
  Rufus.to_time_string(f, opts)
19
19
  end
20
20
 
21
- def tdh (f, opts={})
21
+ def tdh(f, opts={})
22
22
  Rufus.to_duration_hash(f, opts)
23
23
  end
24
24
 
25
- it 'should parse duration strings' do
26
-
27
- pts('5.0').should.equal(5.0)
28
- pts('0.5').should.equal(0.5)
29
- pts('.5').should.equal(0.5)
30
- pts('5.').should.equal(5.0)
31
- pts('500').should.equal(0.5)
32
- pts('1000').should.equal(1.0)
33
- pts('1').should.equal(0.001)
34
- pts('1s').should.equal(1.0)
35
- pts('1h').should.equal(3600.0)
36
- pts('1h10s').should.equal(3610.0)
37
- pts('1w2d').should.equal(777600.0)
38
- pts('1d1w1d').should.equal(777600.0)
25
+ it 'parses duration strings' do
26
+
27
+ pts('5.0').should == 5.0
28
+ pts('0.5').should == 0.5
29
+ pts('.5').should == 0.5
30
+ pts('5.').should == 5.0
31
+ pts('500').should == 0.5
32
+ pts('1000').should == 1.0
33
+ pts('1').should == 0.001
34
+ pts('1s').should == 1.0
35
+ pts('1h').should == 3600.0
36
+ pts('1h10s').should == 3610.0
37
+ pts('1w2d').should == 777600.0
38
+ pts('1d1w1d').should == 777600.0
39
39
  end
40
40
 
41
- it 'should generate duration strings' do
42
-
43
- tts(0).should.equal('0s')
44
- tts(0, :drop_seconds => true).should.equal('0m')
45
- tts(60).should.equal('1m')
46
- tts(61).should.equal('1m1s')
47
- tts(3661).should.equal('1h1m1s')
48
- tts(24 * 3600).should.equal('1d')
49
- tts(7 * 24 * 3600 + 1).should.equal('1w1s')
50
- tts(30 * 24 * 3600 + 1).should.equal('4w2d1s')
51
- tts(30 * 24 * 3600 + 1, :months => true).should.equal('1M1s')
41
+ it 'generates duration strings' do
42
+
43
+ tts(0).should == '0s'
44
+ tts(0, :drop_seconds => true).should == '0m'
45
+ tts(60).should == '1m'
46
+ tts(61).should == '1m1s'
47
+ tts(3661).should == '1h1m1s'
48
+ tts(24 * 3600).should == '1d'
49
+ tts(7 * 24 * 3600 + 1).should == '1w1s'
50
+ tts(30 * 24 * 3600 + 1).should == '4w2d1s'
51
+ tts(30 * 24 * 3600 + 1, :months => true).should == '1M1s'
52
52
  end
53
53
 
54
- it 'should compute duration hashes' do
54
+ it 'computes duration hashes' do
55
55
 
56
- tdh(0).should.equal({})
57
- tdh(0.128).should.equal({ :ms => 128 })
58
- tdh(60.127).should.equal({ :m => 1, :ms => 127 })
59
- tdh(61.127).should.equal({ :m => 1, :s => 1, :ms => 127 })
60
- tdh(61.127, :drop_seconds => true).should.equal({ :m => 1 })
56
+ tdh(0).should == {}
57
+ tdh(0.128).should == { :ms => 128 }
58
+ tdh(60.127).should == { :m => 1, :ms => 127 }
59
+ tdh(61.127).should == { :m => 1, :s => 1, :ms => 127 }
60
+ tdh(61.127, :drop_seconds => true).should == { :m => 1 }
61
61
  end
62
62
  end
63
63
 
64
64
  describe 'rufus/otime#at_to_f' do
65
65
 
66
- def atf (o)
66
+ def atf(o)
67
67
  Rufus.at_to_f(o)
68
68
  end
69
69
 
70
- it 'should turn Time at values to float' do
70
+ it 'turns Time at values to float' do
71
71
 
72
72
  t = Time.now
73
73
  tf = t.to_f.to_i.to_f
74
74
 
75
- atf(t + 2).to_i.to_f.should.equal(tf + 2)
75
+ atf(t + 2).to_i.to_f.should == tf + 2
76
76
  end
77
77
 
78
- it 'should turn String at values to float' do
78
+ it 'turns String at values to float' do
79
79
 
80
- atf('Sat Mar 21 20:08:01 +0900 2009').should.equal(1237633681.0)
81
- atf('Sat Mar 21 20:08:01 -0900 2009').should.equal(1237698481.0)
82
- atf('Sat Mar 21 20:08:01 +0000 2009').should.equal(1237666081.0)
83
- atf('Sat Mar 21 20:08:01 2009').should.equal(1237666081.0)
84
- atf('Mar 21 20:08:01 2009').should.equal(1237666081.0)
85
- atf('2009/03/21 20:08').should.equal(1237666080.0)
80
+ atf('Sat Mar 21 20:08:01 +0900 2009').should == 1237633681.0
81
+ atf('Sat Mar 21 20:08:01 -0900 2009').should == 1237698481.0
82
+ atf('Sat Mar 21 20:08:01 +0000 2009').should == 1237666081.0
83
+ atf('Sat Mar 21 20:08:01 2009').should == 1237666081.0
84
+ atf('Mar 21 20:08:01 2009').should == 1237666081.0
85
+ atf('2009/03/21 20:08').should == 1237666080.0
86
86
  end
87
87
 
88
- it 'should accept integers' do
88
+ it 'accepts integers' do
89
89
 
90
- atf(1).should.equal(1.0)
90
+ atf(1).should == 1.0
91
91
  end
92
92
  end
93
93
 
@@ -5,32 +5,32 @@
5
5
  # Tue May 5 14:47:16 JST 2009
6
6
  #
7
7
 
8
- require File.dirname(__FILE__) + '/spec_base'
8
+ require File.join(File.dirname(__FILE__), '/spec_base')
9
9
 
10
10
 
11
11
  describe Rufus::Scheduler::Schedulable do
12
12
 
13
- before do
13
+ before(:each) do
14
14
  @s = start_scheduler
15
15
  end
16
- after do
16
+ after(:each) do
17
17
  stop_scheduler(@s)
18
18
  end
19
19
 
20
20
  class JobAlpha
21
21
  attr_reader :value
22
- def trigger (params)
22
+ def trigger(params)
23
23
  @value = params
24
24
  end
25
25
  end
26
26
  class JobBravo
27
27
  attr_reader :value
28
- def call (job)
28
+ def call(job)
29
29
  @value = job
30
30
  end
31
31
  end
32
32
 
33
- it 'should schedule via :schedulable' do
33
+ it 'schedules via :schedulable' do
34
34
 
35
35
  j = JobAlpha.new
36
36
 
@@ -38,11 +38,11 @@ describe Rufus::Scheduler::Schedulable do
38
38
 
39
39
  sleep 1.4
40
40
 
41
- j.value.class.should.equal(Hash)
42
- j.value[:job].class.should.equal(Rufus::Scheduler::InJob)
41
+ j.value.class.should == Hash
42
+ j.value[:job].class.should == Rufus::Scheduler::InJob
43
43
  end
44
44
 
45
- it 'should honour schedulables that reply to :call' do
45
+ it 'honours schedulables that reply to :call' do
46
46
 
47
47
  j = JobBravo.new
48
48
 
@@ -50,10 +50,10 @@ describe Rufus::Scheduler::Schedulable do
50
50
 
51
51
  sleep 1.4
52
52
 
53
- j.value.class.should.equal(Rufus::Scheduler::InJob)
53
+ j.value.class.should == Rufus::Scheduler::InJob
54
54
  end
55
55
 
56
- it 'should accept trigger schedulables as second param' do
56
+ it 'accepts trigger schedulables as second param' do
57
57
 
58
58
  j = JobAlpha.new
59
59
 
@@ -61,11 +61,11 @@ describe Rufus::Scheduler::Schedulable do
61
61
 
62
62
  sleep 1.4
63
63
 
64
- j.value.class.should.equal(Hash)
65
- j.value[:job].class.should.equal(Rufus::Scheduler::InJob)
64
+ j.value.class.should == Hash
65
+ j.value[:job].class.should == Rufus::Scheduler::InJob
66
66
  end
67
67
 
68
- it 'should accept call schedulables as second param' do
68
+ it 'accepts call schedulables as second param' do
69
69
 
70
70
  j = JobBravo.new
71
71
 
@@ -73,7 +73,7 @@ describe Rufus::Scheduler::Schedulable do
73
73
 
74
74
  sleep 1.4
75
75
 
76
- j.value.class.should.equal(Rufus::Scheduler::InJob)
76
+ j.value.class.should == Rufus::Scheduler::InJob
77
77
  end
78
78
  end
79
79