Class: RSpec::Sidekiq::Matchers::EnqueuedJobs
- Inherits:
-
Object
- Object
- RSpec::Sidekiq::Matchers::EnqueuedJobs
- Includes:
- Enumerable
- Defined in:
- lib/rspec/sidekiq/matchers/base.rb
Instance Attribute Summary collapse
-
#jobs ⇒ Object
readonly
Returns the value of attribute jobs.
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #includes?(arguments, options, count) ⇒ Boolean
-
#initialize(klass) ⇒ EnqueuedJobs
constructor
A new instance of EnqueuedJobs.
- #minus!(other) ⇒ Object
Constructor Details
#initialize(klass) ⇒ EnqueuedJobs
Returns a new instance of EnqueuedJobs.
117 118 119 |
# File 'lib/rspec/sidekiq/matchers/base.rb', line 117 def initialize(klass) @jobs = unwrap_jobs(klass.jobs).map { |job| EnqueuedJob.new(job) } end |
Instance Attribute Details
#jobs ⇒ Object (readonly)
Returns the value of attribute jobs.
115 116 117 |
# File 'lib/rspec/sidekiq/matchers/base.rb', line 115 def jobs @jobs end |
Instance Method Details
#each(&block) ⇒ Object
136 137 138 |
# File 'lib/rspec/sidekiq/matchers/base.rb', line 136 def each(&block) jobs.each(&block) end |
#includes?(arguments, options, count) ⇒ Boolean
121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/rspec/sidekiq/matchers/base.rb', line 121 def includes?(arguments, , count) matching = jobs.filter { |job| matches?(job, arguments, ) } case count in [:exactly, n] matching.size == n in [:at_least, n] matching.size >= n in [:at_most, n] matching.size <= n else matching.size > 0 end end |
#minus!(other) ⇒ Object
140 141 142 143 144 145 146 |
# File 'lib/rspec/sidekiq/matchers/base.rb', line 140 def minus!(other) self unless other.is_a?(EnqueuedJobs) @jobs -= other.jobs self end |