Class: RSpec::Sidekiq::Matchers::BeProcessedIn

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/sidekiq/matchers/be_processed_in.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected_queue) ⇒ BeProcessedIn

Returns a new instance of BeProcessedIn.



9
10
11
# File 'lib/rspec/sidekiq/matchers/be_processed_in.rb', line 9

def initialize(expected_queue)
  @expected_queue = expected_queue
end

Instance Method Details

#descriptionObject



13
14
15
# File 'lib/rspec/sidekiq/matchers/be_processed_in.rb', line 13

def description
  "be processed in the \"#{@expected_queue}\" queue"
end

#failure_messageObject



17
18
19
# File 'lib/rspec/sidekiq/matchers/be_processed_in.rb', line 17

def failure_message
  "expected #{@klass} to be processed in the \"#{@expected_queue}\" queue but got \"#{@actual}\""
end

#failure_message_when_negatedObject



31
32
33
# File 'lib/rspec/sidekiq/matchers/be_processed_in.rb', line 31

def failure_message_when_negated
  "expected #{@klass} to not be processed in the \"#{@expected_queue}\" queue"
end

#matches?(job) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
28
29
# File 'lib/rspec/sidekiq/matchers/be_processed_in.rb', line 21

def matches?(job)
  @klass = job.is_a?(Class) ? job : job.class
  if @klass.methods.include?(:get_sidekiq_options)
    @actual = @klass.get_sidekiq_options['queue']
  else
    @actual = job.try(:queue_name)
  end
  @actual.to_s == @expected_queue.to_s
end