class RSpec::Rails::Matchers::ActiveJob::Base

def check(jobs)

def check(jobs)
  @matching_jobs, @unmatching_jobs = jobs.partition do |job|
    if job_match?(job) && arguments_match?(job) && queue_match?(job) && at_match?(job)
      args = deserialize_arguments(job)
      @block.call(*args)
      true
    else
      false
    end
  end
  @matching_jobs_count = @matching_jobs.size
  case @expectation_type
  when :exactly then @expected_number == @matching_jobs_count
  when :at_most then @expected_number >= @matching_jobs_count
  when :at_least then @expected_number <= @matching_jobs_count
  end
end