class RSpec::Sidekiq::Matchers::EnqueuedJobs
Attributes
Public Class Methods
Source
# File lib/rspec/sidekiq/matchers/base.rb, line 123 def initialize(klass) @jobs = unwrap_jobs(klass.jobs).map { |job| EnqueuedJob.new(job) } end
Public Instance Methods
Source
# File lib/rspec/sidekiq/matchers/base.rb, line 142 def each(&block) jobs.each(&block) end
Source
# File lib/rspec/sidekiq/matchers/base.rb, line 127 def includes?(arguments, options, count) matching = jobs.filter { |job| matches?(job, arguments, options) } case count[0] when :exactly matching.size == count[1] when :at_least matching.size >= count[1] when :at_most matching.size <= count[1] else matching.size > 0 end end
Source
# File lib/rspec/sidekiq/matchers/base.rb, line 146 def minus!(other) self unless other.is_a?(EnqueuedJobs) @jobs -= other.jobs self end
Private Instance Methods
Source
# File lib/rspec/sidekiq/matchers/base.rb, line 161 def arguments_matches?(job, arguments) job_arguments = JobArguments.new(job) job_arguments.matches?(arguments) end
Source
# File lib/rspec/sidekiq/matchers/base.rb, line 156 def matches?(job, arguments, options) arguments_matches?(job, arguments) && options_matches?(job, options) end
Source
# File lib/rspec/sidekiq/matchers/base.rb, line 167 def options_matches?(job, options) parser = JobOptionParser.new(job) parser.matches?(options) end
Source
# File lib/rspec/sidekiq/matchers/base.rb, line 173 def unwrap_jobs(jobs) return jobs if jobs.is_a?(Array) jobs.values.flatten end