Sha256: b30c2d148ec9b35cd5d2df802374d88fecfc25a6665b049dbadfd78782e4ccae

Contents?: true

Size: 995 Bytes

Versions: 4

Compression:

Stored size: 995 Bytes

Contents

# Defines the match +have_job_queued+ which can be asserted on a queue name
# to check that a particular job is queued.
#
# Example
#
#     :purchasing.should have_job_queued(class: SubscriptionChargeJob
#                                        args: [ 12345, "99.87" ] )
RSpec::Matchers.define :have_job_queued do |expected_job_hash|
  include Resqutils::Spec::ResqueHelpers

  match do |queue_name|
    jobs_matching(queue_name,expected_job_hash).first.size == 1
  end

  failure_message_for_should do |queue_name|
    matching_jobs,all_jobs = jobs_matching(queue_name,expected_job_hash)
    if matching_jobs.empty?
      "No jobs in #{queue_name} matched #{expected_job_hash.inspect} (Found these jobs: #{all_jobs.map(&:inspect).join(',')})"
    elsif matching_jobs.size > 1
      "Mutiple jobs on #{queue_name} matched - try clearing queues before each test"
    end
  end

  failure_message_for_should_not do |queue_name|
    "Found job #{expected_job_hash.inspect} in the queue"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
resqutils-1.1.1 lib/resqutils/spec/resque_matchers.rb
resqutils-1.1.0 lib/resqutils/spec/resque_matchers.rb
resqutils-1.0.0 lib/resqutils/spec/resque_matchers.rb
resqutils-0.0.1 lib/resqutils/spec/resque_matchers.rb