lib/resque_spec.rb in resque_spec-0.1.2 vs lib/resque_spec.rb in resque_spec-0.2.0
- old
+ new
@@ -1,50 +1,2 @@
-require 'resque'
-
-module ResqueSpec
- extend self
-
- def in_queue?(klass, *args)
- queue_for(klass).any? {|entry| entry[:klass] == klass && entry[:args] == args}
- end
-
- def queue_for(klass)
- queue_name = klass.instance_variable_get(:@queue) || klass.respond_to?(:queue) && klass.queue
- raise ::Resque::NoQueueError.new("Jobs must be placed onto a queue.") unless queue_name
- queues[queue_name]
- end
-
- def queues
- @queues ||= Hash.new {|h,k| h[k] = []}
- end
-
- def reset!
- queues.clear
- end
-
- module Resque
- def enqueue(klass, *args)
- ResqueSpec.queue_for(klass) << {:klass => klass, :args => args}
- end
- end
-end
-
-Resque.extend(ResqueSpec::Resque)
-
-Spec::Matchers.define :have_queued do |*expected_args|
- match do |actual|
- ResqueSpec.in_queue?(actual, *expected_args)
- end
-
- failure_message_for_should do |actual|
- "expected that #{actual} would have [#{expected_args.join(', ')}] queued"
- end
-
- failure_message_for_should_not do |actual|
- "expected that #{actual} would not have [#{expected_args.join(', ')}] queued"
- end
-
- description do
- "have queued arguments"
- end
-end
-
+require 'resque_spec/resque_spec'
+require 'resque_spec/resque_scheduler_spec'