Class: RuboCop::Cop::RSpec::SidekiqPerformMatcher
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::RSpec::SidekiqPerformMatcher
- Defined in:
- lib/rubocop/cop/rspec/sidekiq_perform_matcher.rb
Overview
Prevent the use of ‘receive(:perform_async)` matcher to use instead rspec-sidekiq matcher like `enqueue_sidekiq_job`.
Constant Summary collapse
- MSG =
'Use `have_enqueued_sidekiq_job` instead of `receive(:perform_%s)`.'- RESTRICT_ON_SEND =
i[receive].freeze
Instance Method Summary collapse
- #on_send(node) ⇒ Object (also: #on_csend)
- #perform_matcher?(node) ⇒ Object
Instance Method Details
#on_send(node) ⇒ Object Also known as: on_csend
31 32 33 34 35 36 37 |
# File 'lib/rubocop/cop/rspec/sidekiq_perform_matcher.rb', line 31 def on_send(node) return unless perform_matcher?(node) perform_method = node.first_argument.value.to_s.sub('perform_', '') add_offense(node, message: format(MSG, perform_method)) end |
#perform_matcher?(node) ⇒ Object
27 28 29 |
# File 'lib/rubocop/cop/rspec/sidekiq_perform_matcher.rb', line 27 def_node_matcher :perform_matcher?, "(send nil? :receive (sym {:perform_async :perform_in :perform_at :perform_bulk}))\n" |