Sha256: 6e7770d0b11cc597408bbca8d8a9c21812bdb0b1257d8509c4a94f7e9c23b927

Contents?: true

Size: 1.18 KB

Versions: 8

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module SidekiqUniqueJobs
  module RSpec
    #
    # Module Matchers provides RSpec matcher for your workers
    #
    # @author Mikael Henriksson <mikael@zoolutions.se>
    #
    module Matchers
      #
      # Class BeLockable validates the unique/lock configuration for your worker.
      #
      # @author Mikael Henriksson <mikael@zoolutions.se>
      #
      class HaveValidSidekiqOptions
        attr_reader :worker, :lock_config, :sidekiq_options

        def matches?(worker)
          @worker          = worker
          @sidekiq_options = worker.get_sidekiq_options
          @lock_config     = SidekiqUniqueJobs.validate_worker(sidekiq_options)
          lock_config.valid?
        end

        def failure_message
          <<~FAILURE_MESSAGE
            Expected #{worker} to have valid sidekiq options but found the following problems:
            #{lock_config.errors_as_string}
          FAILURE_MESSAGE
        end

        def description
          "have valid sidekiq options"
        end
      end

      def have_valid_sidekiq_options(*args) # rubocop:disable Naming/PredicateName
        HaveValidSidekiqOptions.new(*args)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-7.0.0.beta9 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.0.0.beta8 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.0.0.beta7 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.0.0.beta6 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.0.0.beta5 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.0.0.beta4 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.0.0.beta3 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.0.0.beta2 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb