Module: ScheduleQueueHelper
- Includes:
- QueueHelper
- Defined in:
- lib/activejob_spec/matchers.rb
Instance Method Summary
collapse
#check_size_for, #find_matching_jobs, #queue_size_for
#enqueued_jobs
Methods included from ArgsHelper
#match_args, #match_job
Instance Method Details
#check_for_scheduled(actual, expected_args) ⇒ Object
48
49
50
51
52
53
54
55
|
# File 'lib/activejob_spec/matchers.rb', line 48
def check_for_scheduled(actual, expected_args)
scheduled_jobs.any? do |entry|
class_matches = match_job(entry, actual)
args_match = match_args(expected_args, entry.fetch(:args))
class_matches && args_match && time_matches(entry)
end
end
|
#compare_interval(entry) ⇒ Object
68
69
70
|
# File 'lib/activejob_spec/matchers.rb', line 68
def compare_interval(entry)
entry[:at].to_i == (Time.now + @interval).to_i
end
|
#compare_time(entry) ⇒ Object
64
65
66
|
# File 'lib/activejob_spec/matchers.rb', line 64
def compare_time(entry)
entry[:at].to_i == @time.to_i
end
|
#scheduled_jobs ⇒ Object
72
73
74
|
# File 'lib/activejob_spec/matchers.rb', line 72
def scheduled_jobs
enqueued_jobs.select { |job| job.key?(:at) }
end
|
#scheduled_size_for(actual) ⇒ Object
76
77
78
|
# File 'lib/activejob_spec/matchers.rb', line 76
def scheduled_size_for(actual)
scheduled_jobs.select { |job| match_job(job, actual) }.size
end
|
#time_matches(entry) ⇒ Object
57
58
59
60
61
62
|
# File 'lib/activejob_spec/matchers.rb', line 57
def time_matches(entry)
return compare_time(entry) if @time
return compare_interval(entry) if @interval
true
end
|