Class: RSpec::Sidekiq::Matchers::EnqueueSidekiqJob Private
- Defined in:
- lib/rspec/sidekiq/matchers/enqueue_sidekiq_job.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
-
#original_jobs ⇒ Object
readonly
private
Plus that from Base.
Attributes inherited from Base
#actual_jobs, #expected_arguments, #expected_options, #klass
Instance Method Summary collapse
- #failure_message ⇒ Object private
- #failure_message_when_negated ⇒ Object private
-
#initialize(job_class) ⇒ EnqueueSidekiqJob
constructor
private
A new instance of EnqueueSidekiqJob.
- #matches?(proc) ⇒ Boolean private
- #supports_block_expectations? ⇒ Boolean private
Methods inherited from Base
#at, #description, #formatted, #immediately, #in, #normalize_arguments, #on, #with
Constructor Details
#initialize(job_class) ⇒ EnqueueSidekiqJob
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of EnqueueSidekiqJob.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rspec/sidekiq/matchers/enqueue_sidekiq_job.rb', line 8 def initialize(job_class) super() default = if RSpec::Sidekiq.configuration.sidekiq_gte_7? ::Sidekiq::Job else ::Sidekiq::Worker end @klass = job_class || default end |
Instance Attribute Details
#original_jobs ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Plus that from Base
6 7 8 |
# File 'lib/rspec/sidekiq/matchers/enqueue_sidekiq_job.rb', line 6 def original_jobs @original_jobs end |
Instance Method Details
#failure_message ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
33 34 35 36 37 38 39 |
# File 'lib/rspec/sidekiq/matchers/enqueue_sidekiq_job.rb', line 33 def if @actual_jobs.none? "expected to enqueue a job but enqueued 0" else super end end |
#failure_message_when_negated ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
41 42 43 44 45 46 47 48 |
# File 'lib/rspec/sidekiq/matchers/enqueue_sidekiq_job.rb', line 41 def = ["expected not to enqueue a #{@klass} job but enqueued #{actual_jobs.count}"] << " with arguments #{formatted(expected_arguments)}" if expected_arguments << " with context #{formatted()}" if .join("\n") end |
#matches?(proc) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rspec/sidekiq/matchers/enqueue_sidekiq_job.rb', line 19 def matches?(proc) raise ArgumentError, "Only block syntax supported for enqueue_sidekiq_job" unless Proc === proc @original_jobs = EnqueuedJobs.new(@klass) proc.call @actual_jobs = EnqueuedJobs.new(@klass).minus!(original_jobs) if @actual_jobs.none? return false end @actual_jobs.includes?(expected_arguments, ) end |
#supports_block_expectations? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
50 51 52 |
# File 'lib/rspec/sidekiq/matchers/enqueue_sidekiq_job.rb', line 50 def supports_block_expectations? true end |