Sha256: 16a71241986ad6ac3b5ef69167e70e297a485d34744608a3885262d1a467a5b6

Contents?: true

Size: 1.41 KB

Versions: 61

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

module SidekiqUniqueJobs
  module RSpec
    #
    # Module Matchers provides RSpec matcher for your workers
    #
    # @author Mikael Henriksson <mikael@mhenrixon.com>
    #
    module Matchers
      #
      # Class HaveValidSidekiqOptions validates the unique/lock configuration for a worker.
      #
      # @author Mikael Henriksson <mikael@mhenrixon.com>
      #
      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

        # :nodoc:
        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

        # :nodoc:
        def description
          "have valid sidekiq options"
        end
      end

      #
      # RSpec matcher method for validating that a sidekiq worker has valid unique/lock configuration
      #
      #
      # @return [HaveValidSidekiqOptions] an RSpec matcher
      #
      def have_valid_sidekiq_options(*args) # rubocop:disable Naming/PredicateName
        HaveValidSidekiqOptions.new(*args)
      end
    end
  end
end

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-8.0.10 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.33 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.32 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-8.0.9 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-8.0.8 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-8.0.7 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-8.0.6 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.31 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-8.0.5 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-8.0.4 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.30 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-8.0.3 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-8.0.2 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-8.0.1 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-8.0.0 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.29 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.28 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.27 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.26 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.25 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb