Sha256: cf76078e8ad5c6615b29ba4da28fa352c3d74373ce454b1c1703314124b09b98

Contents?: true

Size: 913 Bytes

Versions: 5

Compression:

Stored size: 913 Bytes

Contents

module RSpec
  module Sidekiq
    module Matchers
      def have_enqueued_jobs expected
        HaveEnqueuedJobs.new expected
      end

      class HaveEnqueuedJobs
        def initialize expected
          @expected = expected
        end

        def description
          "have #{@expected} enqueued #{@klass} job#{jobs_description}"
        end

        def failure_message
          "expected #{@klass} to have #{@expected} enqueued job#{jobs_description} but got #{@actual}"
        end

        def jobs_description
          "s" unless @expected == 1
        end

        def matches? klass
          @klass = klass
          @actual = klass.jobs.size
          @actual == @expected
        end
        
        def negative_failure_message
          "expected #{@klass} to not have #{@expected} enqueued job#{jobs_description}"
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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