Sha256: b591e01692ef206c7f200ccd82641e670803db086f04d1fe2a9cded48c215e91

Contents?: true

Size: 1005 Bytes

Versions: 1

Compression:

Stored size: 1005 Bytes

Contents

module RSpec
  module Sidekiq
    module Matchers
      def be_retryable expected
        BeRetryable.new expected
      end

      class BeRetryable
        def initialize expected
          @expected = expected
        end

        def description
          if @expected.is_a?(Fixnum)
            "retry #{@expected} times"          # retry: 5
          elsif @expected
            "retry the default number of times" # retry: true
          else
            "not retry"                         # retry: false
          end
        end

        def failure_message
          "expected #{@klass} to #{description} but got #{@actual}"
        end

        def matches? job
          @klass = job.kind_of?(Class) ? job : job.class
          @actual = @klass.get_sidekiq_options["retry"]
          @actual == @expected
        end
        
        def negative_failure_message
          "expected #{@klass} to not #{description}"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-sidekiq-0.4.0 lib/rspec/sidekiq/matchers/be_retryable.rb