Sha256: 7fc11525716f1af6c432fef23a0d4eeb19d96761c17e88fe45229ebe1a882f7f

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

module RSpec
  module Sidekiq
    module Matchers
      def have_enqueued_sidekiq_job(*expected_arguments)
        HaveEnqueuedSidekiqJob.new expected_arguments
      end

      # @api private
      class HaveEnqueuedSidekiqJob < Base
        DEPRECATION = [
          "[WARNING] `have_enqueued_sidekiq_job()` without arguments default behavior will change in next major release.",
          "Use `have_enqueued_sidekiq_job(no_args)` to maintain legacy behavior.",
          "More available here: https://github.com/wspurgin/rspec-sidekiq/wiki/have_enqueued_sidekiq_job-without-argument-default-behavior"
        ].join(" ").freeze

        def initialize(expected_arguments)
          super()

          if expected_arguments == [] && RSpec::Sidekiq.configuration.warn_for?(:have_enqueued_sidekiq_job_default)
            Kernel.warn(DEPRECATION, uplevel: 3)
          end
          @expected_arguments = normalize_arguments(expected_arguments)
        end

        def matches?(job_class)
          @klass = job_class

          @actual_jobs = EnqueuedJobs.new(klass)
          actual_jobs.includes?(expected_arguments, expected_options)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-sidekiq-4.2.0 lib/rspec/sidekiq/matchers/have_enqueued_sidekiq_job.rb