Class: SidekiqUniqueJobs::RSpec::Matchers::HaveValidSidekiqOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb

Overview

Class HaveValidSidekiqOptions validates the unique/lock configuration for a worker.

Author:

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#lock_configObject (readonly)

Returns the value of attribute lock_config.



17
18
19
# File 'lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb', line 17

def lock_config
  @lock_config
end

#sidekiq_optionsObject (readonly)

Returns the value of attribute sidekiq_options.



17
18
19
# File 'lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb', line 17

def sidekiq_options
  @sidekiq_options
end

#workerObject (readonly)

Returns the value of attribute worker.



17
18
19
# File 'lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb', line 17

def worker
  @worker
end

Instance Method Details

#descriptionObject

:nodoc:



35
36
37
# File 'lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb', line 35

def description
  "have valid sidekiq options"
end

#failure_messageObject

:nodoc:



27
28
29
30
31
32
# File 'lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb', line 27

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

#matches?(worker) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
# File 'lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb', line 19

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