Class: RuboCop::Cop::Sidekiq::AsyncInTest

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/sidekiq/async_in_test.rb

Overview

Checks for perform_async usage in test files.

Examples:

# bad
MyJob.perform_async(user.id)

# good
MyJob.perform_inline(user.id)

Constant Summary collapse

MSG =
'Avoid perform_async in tests. Use perform_inline or call perform directly.'
RESTRICT_ON_SEND =
%i[perform_async].freeze

Instance Method Summary collapse

Methods included from Sidekiq::Language

#active_job_class?, #perform_call?, #sidekiq_include?, #sidekiq_options_call?

Instance Method Details

#on_send(node) ⇒ Object Also known as: on_csend



20
21
22
23
24
# File 'lib/rubocop/cop/sidekiq/async_in_test.rb', line 20

def on_send(node)
  return unless in_test_file?

  add_offense(node)
end