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

def check(jobs)

def check(jobs)
  @matching_jobs_count = jobs.count do |job|
    if serialized_attributes.all? { |key, value| value == job[key] }
      @block.call(*job[:args])
      true
    else
      false
    end
  end
  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