lib/resque_spec.rb in resque_spec-0.6.2 vs lib/resque_spec.rb in resque_spec-0.6.3
- old
+ new
@@ -7,20 +7,16 @@
attr_accessor :inline
def dequeue(queue_name, klass, *args)
queue_by_name(queue_name).delete_if do |job|
- job[:klass] == klass.to_s && args.empty? || job[:args] == args
+ job[:class] == klass.to_s && args.empty? || job[:args] == args
end
end
def enqueue(queue_name, klass, *args)
- if inline
- klass.send(:perform, *args)
- else
- queue_by_name(queue_name) << { :klass => klass.to_s, :args => args }
- end
+ store(queue_name, klass, { :class => klass.to_s, :args => args })
end
def queue_by_name(name)
queues[name]
end
@@ -53,9 +49,24 @@
klass.instance_variable_get(:@queue)
end
def name_from_queue_accessor(klass)
klass.respond_to?(:queue) and klass.queue
+ end
+
+ def store(queue_name, klass, payload)
+ if inline
+ Resque::Job.new(queue_name, payload_with_string_keys(payload)).perform
+ else
+ queue_by_name(queue_name) << payload
+ end
+ end
+
+ def payload_with_string_keys(payload)
+ {
+ 'class' => payload[:class],
+ 'args' => payload[:args]
+ }
end
end
config = RSpec.configuration
config.include ResqueSpec::Helpers