Class: RSpec::Sidekiq::Matchers::EnqueueSidekiqJob Private

Inherits:
Base
  • Object
show all
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

Attributes inherited from Base

#actual_jobs, #expected_arguments, #expected_count, #expected_options, #klass

Instance Method Summary collapse

Methods inherited from Base

#at, #at_least, #at_most, #common_message, #count_message, #description, #exactly, #failure_message, #failure_message_when_negated, #formatted, #immediately, #in, #normalize_arguments, #on, #once, #set_expected_count, #thrice, #times, #twice, #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_jobsObject (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

#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.

Returns:

  • (Boolean)

Raises:

  • (ArgumentError)


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, expected_options, expected_count)
end

#prefix_messageObject

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
# File 'lib/rspec/sidekiq/matchers/enqueue_sidekiq_job.rb', line 33

def prefix_message
  "enqueue"
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.

Returns:

  • (Boolean)


37
38
39
# File 'lib/rspec/sidekiq/matchers/enqueue_sidekiq_job.rb', line 37

def supports_block_expectations?
  true
end