Module: ResqueSpec

Extended by:
ResqueSpec
Included in:
ResqueSpec
Defined in:
lib/resque_spec/version.rb,
lib/resque_spec/resque_spec.rb,
lib/resque_spec/resque_scheduler_spec.rb

Defined Under Namespace

Modules: Resque, ResqueScheduler

Constant Summary collapse

VERSION =
'0.2.3.1'

Instance Method Summary collapse

Instance Method Details

#in_queue?(klass, *args) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/resque_spec/resque_spec.rb', line 7

def in_queue?(klass, *args)
  queue_for(klass).any? {|entry| entry[:klass] == klass && entry[:args] == args}
end

#queue_for(klass) ⇒ Object



11
12
13
# File 'lib/resque_spec/resque_spec.rb', line 11

def queue_for(klass)
  queues[queue_name(klass)]
end

#queue_name(klass) ⇒ Object



15
16
17
18
19
# File 'lib/resque_spec/resque_spec.rb', line 15

def queue_name(klass)
  name_from_instance_var(klass) or
    name_from_queue_accessor(klass) or
    raise ::Resque::NoQueueError.new("Jobs must be placed onto a queue.")
end

#queuesObject



21
22
23
# File 'lib/resque_spec/resque_spec.rb', line 21

def queues
  @queues ||= Hash.new {|h,k| h[k] = []}
end

#reset!Object



25
26
27
# File 'lib/resque_spec/resque_spec.rb', line 25

def reset!
  queues.clear
end

#schedule_for(klass) ⇒ Object



13
14
15
16
# File 'lib/resque_spec/resque_scheduler_spec.rb', line 13

def schedule_for(klass)
  name = queue_name(klass).to_s << "_scheduled"
  queues[name]
end

#scheduled?(klass, time, *args) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/resque_spec/resque_scheduler_spec.rb', line 5

def scheduled?(klass, time, *args)
  schedule_for(klass).any? {|entry| entry[:klass] == klass && entry[:time] == time && entry[:args] == args}
end

#scheduled_anytime?(klass, *args) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/resque_spec/resque_scheduler_spec.rb', line 9

def scheduled_anytime?(klass, *args)
  schedule_for(klass).any? {|entry| entry[:klass] == klass && entry[:args] == args}
end