Sha256: 903f5a9ffe7c476ceddbf9f7b7efd252fedcbfabed328f021b911e482837d3bc

Contents?: true

Size: 886 Bytes

Versions: 4

Compression:

Stored size: 886 Bytes

Contents

module RSpec
  module Sidekiq
    module Matchers
      def have_enqueued_job *expected
        HaveEnqueuedJob.new expected
      end

      class HaveEnqueuedJob
        def initialize expected
          @expected = expected
        end

        def description
          "have an enqueued #{@klass} job with arguments #{@expected}"
        end

        def failure_message
          "expected to have an enqueued #{@klass} job with arguments #{@expected} but none found\n\n" +
          "found: #{@actual}"
        end

        def matches? klass
          @klass = klass
          @actual = klass.jobs.map { |job| job["args"] }
          @actual.include? @expected
        end
        
        def negative_failure_message
          "expected to not have an enqueued #{@klass} job with arguments #{@expected}"
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rspec-sidekiq-0.4.0 lib/rspec/sidekiq/matchers/have_enqueued_job.rb
rspec-sidekiq-0.3.0 lib/rspec/sidekiq/matchers/have_enqueued_job.rb
rspec-sidekiq-0.2.2 lib/rspec/sidekiq/matchers/have_enqueued_job.rb
rspec-sidekiq-0.2.1 lib/rspec/sidekiq/matchers/have_enqueued_job.rb