class RSpec::Sidekiq::Matchers::JobOptionParser

@api private

Attributes

job[R]

Public Class Methods

new(job) click to toggle source
# File lib/rspec/sidekiq/matchers/base.rb, line 8
def initialize(job)
  @job = job
end

Public Instance Methods

matches?(options) click to toggle source
# File lib/rspec/sidekiq/matchers/base.rb, line 12
def matches?(options)
  with_context(**options)
end

Private Instance Methods

at_evaluator(value) click to toggle source
# File lib/rspec/sidekiq/matchers/base.rb, line 18
def at_evaluator(value)
  return value.nil? if job["at"].to_s.empty?
  value == Time.at(job["at"]).to_i
end
with_context(**expected_context) click to toggle source
# File lib/rspec/sidekiq/matchers/base.rb, line 23
def with_context(**expected_context)
  expected_context.all? do |key, value|
    if key == "at"
      # send to custom evaluator
      at_evaluator(value)
    else
      job.context.has_key?(key) && job.context[key] == value
    end
  end
end