Class: GLRubocop::GLCops::NoStubbingPerformAsync

Inherits:
RuboCop::Cop::Cop
  • Object
show all
Defined in:
lib/gl_rubocop/gl_cops/no_stubbing_perform_async.rb

Overview

Bad:

allow(ExampleWorker).to receive(:perform_async)
expect(ExampleWorker).to receive(:perform_async)
expect(SomeWorker).not_to have_received(:perform_in)

Constant Summary collapse

MSG =
"Don't stub perform async. Use the rspec-sidekick matchers instead: " \
'expect(JobClass).to have_enqueued_sidekiq_job'.freeze

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/gl_rubocop/gl_cops/no_stubbing_perform_async.rb', line 29

def on_send(node)
  return unless have_received_perform?(node) || receive_perform?(node)

  # Find the expect or allow context
  offense_node = find_offense_node(node)
  add_offense(offense_node) if offense_node
end