Sha256: e1481bb2c45b17a83a03f96005464ba7bdfcf5a48fac9b78895e1e29bc89ff5b

Contents?: true

Size: 977 Bytes

Versions: 2

Compression:

Stored size: 977 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.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

2 entries across 2 versions & 1 rubygems

Version Path
rspec-sidekiq-0.3.0 lib/rspec/sidekiq/matchers/be_retryable.rb
rspec-sidekiq-0.2.2 lib/rspec/sidekiq/matchers/be_retryable.rb