resque_unit 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/lib/resque_unit.rb CHANGED
@@ -3,6 +3,7 @@ end
3
3
 
4
4
  require 'test/unit'
5
5
  require 'resque_unit/resque'
6
+ require 'resque_unit/errors'
6
7
  require 'resque_unit/assertions'
7
8
 
8
9
 
@@ -0,0 +1,17 @@
1
+ # Re-define errors in from Resque, in case the 'resque' gem was not loaded.
2
+ module Resque
3
+ # Raised whenever we need a queue but none is provided.
4
+ unless defined?(NoQueueError)
5
+ class NoQueueError < RuntimeError; end
6
+ end
7
+
8
+ # Raised when trying to create a job without a class
9
+ unless defined?(NoClassError)
10
+ class NoClassError < RuntimeError; end
11
+ end
12
+
13
+ # Raised when a worker was killed while processing a job.
14
+ unless defined?(DirtyExit)
15
+ class DirtyExit < RuntimeError; end
16
+ end
17
+ end
@@ -54,7 +54,10 @@ module Resque
54
54
 
55
55
  # :nodoc:
56
56
  def self.enqueue(klass, *args)
57
- queue(queue_for(klass)) << {:klass => klass, :args => args}
57
+ queue_name = queue_for(klass)
58
+ # Behaves like Resque, raise if no queue was specifed
59
+ raise NoQueueError.new("Jobs must be placed onto a queue.") unless queue_name
60
+ queue(queue_name) << {:klass => klass, :args => args}
58
61
  end
59
62
 
60
63
  # :nodoc:
@@ -202,4 +202,13 @@ class ResqueUnitTest < Test::Unit::TestCase
202
202
  end
203
203
  end
204
204
  end
205
+
206
+ context "A job that does not specify a queue" do
207
+ should "receive Resque::NoQueueError" do
208
+ assert_raise(Resque::NoQueueError) do
209
+ Resque.enqueue(JobThatDoesNotSpecifyAQueue)
210
+ end
211
+ end
212
+ end
213
+
205
214
  end
data/test/sample_jobs.rb CHANGED
@@ -42,3 +42,9 @@ class JobThatCreatesANewJob
42
42
  Resque.enqueue(LowPriorityJob)
43
43
  end
44
44
  end
45
+
46
+ class JobThatDoesNotSpecifyAQueue
47
+
48
+ def self.perform
49
+ end
50
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque_unit
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 5
10
- version: 0.2.5
9
+ - 6
10
+ version: 0.2.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Justin Weiss
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-03 00:00:00 -07:00
18
+ date: 2010-10-18 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -42,6 +42,7 @@ extra_rdoc_files:
42
42
  - README.md
43
43
  files:
44
44
  - lib/resque_unit/assertions.rb
45
+ - lib/resque_unit/errors.rb
45
46
  - lib/resque_unit/resque.rb
46
47
  - lib/resque_unit/scheduler.rb
47
48
  - lib/resque_unit/scheduler_assertions.rb