resque_unit 0.4.8 → 1.0.0.beta.2

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,230 +1,232 @@
1
1
  require 'test_helper'
2
2
  require 'resque_unit_scheduler'
3
3
 
4
- class ResqueUnitSchedulerTest < Test::Unit::TestCase
5
-
6
- def setup
4
+ describe Resque do
5
+ include ResqueUnit::Assertions
6
+ include ResqueUnit::SchedulerAssertions
7
+
8
+ before do
7
9
  Resque.reset!
8
10
  end
9
11
 
10
- context "A task that schedules a resque job in 5 minutes" do
11
- setup { Resque.enqueue_in(600, MediumPriorityJob) }
12
- should "pass the assert_queued(job) assertion" do
12
+ describe "A task that schedules a resque job in 5 minutes" do
13
+ before { Resque.enqueue_in(600, MediumPriorityJob) }
14
+ it "passes the assert_queued(job) assertion" do
13
15
  assert_queued(MediumPriorityJob)
14
16
  end
15
17
 
16
- should "pass the assert_queued_in(600, job) assertion" do
18
+ it "passes the assert_queued_in(600, job) assertion" do
17
19
  assert_queued_in(600, MediumPriorityJob)
18
20
  end
19
21
 
20
- should "fail the assert_queued_in(300, job) assertion" do
21
- assert_raise Test::Unit::AssertionFailedError do
22
+ it "fails the assert_queued_in(300, job) assertion" do
23
+ assert_raises Minitest::Assertion do
22
24
  assert_queued_in(300, MediumPriorityJob)
23
25
  end
24
26
  end
25
27
 
26
- should "pass the assert_not_queued_in(300, job) assertion" do
28
+ it "passes the assert_not_queued_in(300, job) assertion" do
27
29
  assert_not_queued_in(300, MediumPriorityJob)
28
30
  end
29
31
 
30
- context "and then the job is removed with #remove_delayed" do
31
- setup do
32
+ describe "and then the job is removed with #remove_delayed" do
33
+ before do
32
34
  Resque.remove_delayed(MediumPriorityJob)
33
35
  end
34
- should "pass the assert_not_queued_at(@time, MediumPriorityJob) assertion" do
36
+ it "passes the assert_not_queued_at(@time, MediumPriorityJob) assertion" do
35
37
  assert_not_queued_at(300, MediumPriorityJob)
36
38
  end
37
39
 
38
- should "fail the assert_queued_at(@time, MediumPriorityJob) assertion" do
39
- assert_raise Test::Unit::AssertionFailedError do
40
+ it "fails the assert_queued_at(@time, MediumPriorityJob) assertion" do
41
+ assert_raises Minitest::Assertion do
40
42
  assert_queued_at(300, MediumPriorityJob)
41
43
  end
42
44
  end
43
45
  end
44
46
  end
45
47
 
46
- context "A task that schedules a resque job in 5 minutes with arguments" do
47
- setup { Resque.enqueue_in(600, JobWithArguments, 1, "test") }
48
- should "pass the assert_queued_in(600, JobWithArguments) assertion" do
48
+ describe "A task that schedules a resque job in 5 minutes with arguments" do
49
+ before { Resque.enqueue_in(600, JobWithArguments, 1, "test") }
50
+ it "passes the assert_queued_in(600, JobWithArguments) assertion" do
49
51
  assert_queued_in(600, JobWithArguments)
50
52
  end
51
53
 
52
- should "pass the assert_queued_in(600, JobWithArguments, [1, 'test']) assertion" do
54
+ it "passes the assert_queued_in(600, JobWithArguments, [1, 'test']) assertion" do
53
55
  assert_queued_in(600, JobWithArguments, [1, 'test'])
54
56
  end
55
57
 
56
- should "fail the assert_queued_in(600, JobWithArguments, [2, 'test']) assertion" do
57
- assert_raise Test::Unit::AssertionFailedError do
58
+ it "fails the assert_queued_in(600, JobWithArguments, [2, 'test']) assertion" do
59
+ assert_raises Minitest::Assertion do
58
60
  assert_queued_in(600, JobWithArguments, [2, 'test'])
59
61
  end
60
62
  end
61
63
 
62
- context "and then the job is removed with #remove_delayed" do
63
- setup do
64
+ describe "and then the job is removed with #remove_delayed" do
65
+ before do
64
66
  Resque.remove_delayed(JobWithArguments, 1, 'test')
65
67
  end
66
- should "pass the assert_not_queued_at(@time, JobWithArguments, 1, 'test') assertion" do
68
+ it "passes the assert_not_queued_at(@time, JobWithArguments, 1, 'test') assertion" do
67
69
  assert_not_queued_at(600, JobWithArguments, 1, 'test')
68
70
  end
69
71
 
70
- should "fail the assert_queued_at(@time, JobWithArguments, 1, 'test') assertion" do
71
- assert_raise Test::Unit::AssertionFailedError do
72
+ it "fails the assert_queued_at(@time, JobWithArguments, 1, 'test') assertion" do
73
+ assert_raises Minitest::Assertion do
72
74
  assert_queued_at(600, JobWithArguments, 1, 'test')
73
75
  end
74
76
  end
75
77
  end
76
78
 
77
- context "and a job of the same class but with different arguments is removed with #remove_delayed" do
78
- setup do
79
+ describe "and a job of the same class but with different arguments is removed with #remove_delayed" do
80
+ before do
79
81
  Resque.remove_delayed(JobWithArguments, 2, 'test')
80
82
  end
81
- should "still pass the assert_queued_in(600, JobWithArguments) assertion" do
83
+ it "still passes the assert_queued_in(600, JobWithArguments) assertion" do
82
84
  assert_queued_in(600, JobWithArguments)
83
85
  end
84
86
 
85
- should "still pass the assert_queued_in(600, JobWithArguments, [1, 'test']) assertion" do
87
+ it "still passes the assert_queued_in(600, JobWithArguments, [1, 'test']) assertion" do
86
88
  assert_queued_in(600, JobWithArguments, [1, 'test'])
87
89
  end
88
90
 
89
- should "still fail the assert_queued_in(600, JobWithArguments, [2, 'test']) assertion" do
90
- assert_raise Test::Unit::AssertionFailedError do
91
+ it "still fails the assert_queued_in(600, JobWithArguments, [2, 'test']) assertion" do
92
+ assert_raises Minitest::Assertion do
91
93
  assert_queued_in(600, JobWithArguments, [2, 'test'])
92
94
  end
93
95
  end
94
96
  end
95
97
  end
96
98
 
97
- context "A task that schedules a resque job on Sept. 6, 2016 at 6am" do
98
- setup do
99
+ describe "A task that schedules a resque job on Sept. 6, 2016 at 6am" do
100
+ before do
99
101
  @time = Time.mktime(2016, 9, 6, 6)
100
102
  Resque.enqueue_at(@time, MediumPriorityJob)
101
103
  end
102
104
 
103
- should "pass the assert_queued_at(@time, MediumPriorityJob) assertion" do
105
+ it "passes the assert_queued_at(@time, MediumPriorityJob) assertion" do
104
106
  assert_queued_at(@time, MediumPriorityJob)
105
107
  end
106
108
 
107
- should "fail the assert_queued_at(@time - 100, MediumPriorityJob) assertion" do
108
- assert_raise Test::Unit::AssertionFailedError do
109
+ it "fails the assert_queued_at(@time - 100, MediumPriorityJob) assertion" do
110
+ assert_raises Minitest::Assertion do
109
111
  assert_queued_at(@time - 100, MediumPriorityJob)
110
112
  end
111
113
  end
112
114
 
113
- should "pass the assert_not_queued_at(@time - 100, MediumPriorityJob) assertion" do
115
+ it "passes the assert_not_queued_at(@time - 100, MediumPriorityJob) assertion" do
114
116
  assert_not_queued_at(@time - 100, MediumPriorityJob)
115
117
  end
116
118
 
117
- context "and then the job is removed with #remove_delayed" do
118
- setup do
119
+ describe "and then the job is removed with #remove_delayed" do
120
+ before do
119
121
  Resque.remove_delayed(MediumPriorityJob)
120
122
  end
121
- should "pass the assert_not_queued_at(@time, MediumPriorityJob) assertion" do
123
+ it "passes the assert_not_queued_at(@time, MediumPriorityJob) assertion" do
122
124
  assert_not_queued_at(@time, MediumPriorityJob)
123
125
  end
124
126
 
125
- should "fail the assert_queued_at(@time, MediumPriorityJob) assertion" do
126
- assert_raise Test::Unit::AssertionFailedError do
127
+ it "fails the assert_queued_at(@time, MediumPriorityJob) assertion" do
128
+ assert_raises Minitest::Assertion do
127
129
  assert_queued_at(@time, MediumPriorityJob)
128
130
  end
129
131
  end
130
132
  end
131
133
 
132
- context "and then the job is removed with #remove_delayed_job_from_timestamp" do
133
- setup do
134
+ describe "and then the job is removed with #remove_delayed_job_from_timestamp" do
135
+ before do
134
136
  Resque.remove_delayed_job_from_timestamp(@time, MediumPriorityJob)
135
137
  end
136
138
 
137
- should "pass the assert_not_queued_at(@time, MediumPriorityJob) assertion" do
139
+ it "passes the assert_not_queued_at(@time, MediumPriorityJob) assertion" do
138
140
  assert_not_queued_at(@time, MediumPriorityJob)
139
141
  end
140
142
 
141
- should "fail the assert_queued_at(@time, MediumPriorityJob) assertion" do
142
- assert_raise Test::Unit::AssertionFailedError do
143
+ it "fails the assert_queued_at(@time, MediumPriorityJob) assertion" do
144
+ assert_raises Minitest::Assertion do
143
145
  assert_queued_at(@time, MediumPriorityJob)
144
146
  end
145
147
  end
146
148
  end
147
149
 
148
- context "and then the job is removed with #remove_delayed_job_from_timestamp with timestamp specified in another timezone" do
149
- setup do
150
+ describe "and then the job is removed with #remove_delayed_job_from_timestamp with timestamp specified in another timezone" do
151
+ before do
150
152
  Resque.remove_delayed_job_from_timestamp(@time.utc, MediumPriorityJob)
151
153
  end
152
154
 
153
- should "pass the assert_not_queued_at(@time, MediumPriorityJob) assertion" do
155
+ it "passes the assert_not_queued_at(@time, MediumPriorityJob) assertion" do
154
156
  assert_not_queued_at(@time, MediumPriorityJob)
155
157
  end
156
158
 
157
- should "fail the assert_queued_at(@time, MediumPriorityJob) assertion" do
158
- assert_raise Test::Unit::AssertionFailedError do
159
+ it "fails the assert_queued_at(@time, MediumPriorityJob) assertion" do
160
+ assert_raises Minitest::Assertion do
159
161
  assert_queued_at(@time, MediumPriorityJob)
160
162
  end
161
163
  end
162
164
  end
163
165
  end
164
166
 
165
- context "A task that schedules a resque job with arguments on on Sept. 6, 2016 at 6am" do
166
- setup do
167
+ describe "A task that schedules a resque job with arguments on on Sept. 6, 2016 at 6am" do
168
+ before do
167
169
  @time = Time.mktime(2016, 9, 6, 6)
168
170
  Resque.enqueue_at(@time, JobWithArguments, 1, "test")
169
171
  end
170
172
 
171
- should "pass the assert_queued_at(@time, JobWithArguments, *args) assertion" do
173
+ it "passes the assert_queued_at(@time, JobWithArguments, *args) assertion" do
172
174
  assert_queued_at(@time, JobWithArguments, [1, "test"])
173
175
  end
174
176
 
175
- should "fail the assert_queued_at(@time - 100, JobWithArguments, *args) assertion" do
176
- assert_raise Test::Unit::AssertionFailedError do
177
+ it "fails the assert_queued_at(@time - 100, JobWithArguments, *args) assertion" do
178
+ assert_raises Minitest::Assertion do
177
179
  assert_queued_at(@time - 100, JobWithArguments, [1, "test"])
178
180
  end
179
181
  end
180
182
 
181
- should "pass the assert_not_queued_at(@time - 100, JobWithArguments, *args) assertion" do
183
+ it "passes the assert_not_queued_at(@time - 100, JobWithArguments, *args) assertion" do
182
184
  assert_not_queued_at(@time - 100, JobWithArguments, [1, "test"])
183
185
  end
184
186
 
185
- context "and then the job is removed with #remove_delayed" do
186
- setup do
187
+ describe "and then the job is removed with #remove_delayed" do
188
+ before do
187
189
  Resque.remove_delayed(JobWithArguments, 1, "test")
188
190
  end
189
191
 
190
- should "pass the assert_not_queued_at(@time, JobWithArguments, *args) assertion" do
192
+ it "passes the assert_not_queued_at(@time, JobWithArguments, *args) assertion" do
191
193
  assert_not_queued_at(@time, JobWithArguments, [1, "test"])
192
194
  end
193
195
 
194
- should "fail the assert_queued_at(@time, JobWithArguments, *args) assertion" do
195
- assert_raise Test::Unit::AssertionFailedError do
196
+ it "fails the assert_queued_at(@time, JobWithArguments, *args) assertion" do
197
+ assert_raises Minitest::Assertion do
196
198
  assert_queued_at(@time, JobWithArguments, [1, "test"])
197
199
  end
198
200
  end
199
201
  end
200
202
 
201
- context "and then the job is removed with #remove_delayed_job_from_timestamp" do
202
- setup do
203
+ describe "and then the job is removed with #remove_delayed_job_from_timestamp" do
204
+ before do
203
205
  Resque.remove_delayed_job_from_timestamp(@time, JobWithArguments, 1, "test")
204
206
  end
205
207
 
206
- should "pass the assert_not_queued_at(@time, JobWithArguments, *args) assertion" do
208
+ it "pass the assert_not_queued_at(@time, JobWithArguments, *args) assertion" do
207
209
  assert_not_queued_at(@time, JobWithArguments, [1, "test"])
208
210
  end
209
211
 
210
- should "fail the assert_queued_at(@time, MediumPriorityJob, *args) assertion" do
211
- assert_raise Test::Unit::AssertionFailedError do
212
+ it "fail the assert_queued_at(@time, MediumPriorityJob, *args) assertion" do
213
+ assert_raises Minitest::Assertion do
212
214
  assert_queued_at(@time, JobWithArguments, [1, "test"])
213
215
  end
214
216
  end
215
217
  end
216
218
 
217
- context "and then the job is removed with #remove_delayed_job_from_timestamp with timestamp in another timezone" do
218
- setup do
219
+ describe "and then the job is removed with #remove_delayed_job_from_timestamp with timestamp in another timezone" do
220
+ before do
219
221
  Resque.remove_delayed_job_from_timestamp(@time.utc, JobWithArguments, 1, "test")
220
222
  end
221
223
 
222
- should "pass the assert_not_queued_at(@time, JobWithArguments, *args) assertion" do
224
+ it "passes the assert_not_queued_at(@time, JobWithArguments, *args) assertion" do
223
225
  assert_not_queued_at(@time, JobWithArguments, [1, "test"])
224
226
  end
225
227
 
226
- should "fail the assert_queued_at(@time, MediumPriorityJob, *args) assertion" do
227
- assert_raise Test::Unit::AssertionFailedError do
228
+ it "fails the assert_queued_at(@time, MediumPriorityJob, *args) assertion" do
229
+ assert_raises Minitest::Assertion do
228
230
  assert_queued_at(@time, JobWithArguments, [1, "test"])
229
231
  end
230
232
  end