class RSpec::Sidekiq::Matchers::JobArguments
@api private
Attributes
Public Class Methods
Source
# File lib/rspec/sidekiq/matchers/base.rb, line 41 def initialize(job) self.job = job end
Public Instance Methods
Source
# File lib/rspec/sidekiq/matchers/base.rb, line 46 def matches?(expected_args) matcher = RSpec::Mocks::ArgumentListMatcher.new(*expected_args) matcher.args_match?(*unwrapped_arguments) end
Source
# File lib/rspec/sidekiq/matchers/base.rb, line 52 def unwrapped_arguments args = job["args"] return deserialized_active_job_args if active_job? args end
Private Instance Methods
Source
# File lib/rspec/sidekiq/matchers/base.rb, line 62 def active_job? if RSpec::Sidekiq.configuration.sidekiq_gte_8? job["class"] == "Sidekiq::ActiveJob::Wrapper" else job["class"] == "ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper" end end
Source
# File lib/rspec/sidekiq/matchers/base.rb, line 83 def active_job_original_args active_job_args = job["args"].detect { |arg| arg.is_a?(Hash) && arg.key?("arguments") } active_job_args ||= {} active_job_args["arguments"] || [] end
Source
# File lib/rspec/sidekiq/matchers/base.rb, line 70 def deserialized_active_job_args active_job_args = ActiveJob::Arguments.deserialize(active_job_original_args) # ActiveJob 7 (aj7) changed deserialization structure, adding passed arguments # in an aj-specific hash under the :args key aj7_args_hash = active_job_args.detect { |arg| arg.respond_to?(:key) && arg.key?(:args) } return active_job_args if aj7_args_hash.nil? active_job_args.delete(aj7_args_hash) active_job_args.concat(aj7_args_hash[:args]) end