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.
193 194 195 |
# File 'lib/rspec/sidekiq/matchers/base.rb', line 193 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.
191 192 193 |
# File 'lib/rspec/sidekiq/matchers/base.rb', line 191 def jobs @jobs end |
Instance Method Details
#each(&block) ⇒ Object
212 213 214 |
# File 'lib/rspec/sidekiq/matchers/base.rb', line 212 def each(&block) jobs.each(&block) end |
#includes?(arguments, options, count) ⇒ Boolean
197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/rspec/sidekiq/matchers/base.rb', line 197 def includes?(arguments, , count) matching = jobs.filter { |job| matches?(job, arguments, ) } 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 |
#minus!(other) ⇒ Object
216 217 218 219 220 221 222 |
# File 'lib/rspec/sidekiq/matchers/base.rb', line 216 def minus!(other) return self unless other.is_a?(EnqueuedJobs) @jobs -= other.jobs self end |