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-7.1.24 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.23 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.22 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.21 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.20 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.19 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.18 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.17 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.16 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.15 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.14 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.13 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.12 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.11 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.10 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.8 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.0.13 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.7 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.6 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb
sidekiq-unique-jobs-7.1.5 lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb