Sha256: da8f107e402bcbe821afe5863bef0cf1b372235fa789f99462cc48f70345e3c9

Contents?: true

Size: 692 Bytes

Versions: 12

Compression:

Stored size: 692 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Discourse
      class NoMockingJobs < Cop
        MSG = "Use the test helpers provided by Sidekiq instead of mocking `Jobs.expects(:enqueue)`."

        def_node_matcher :mocking_jobs_enqueue?, <<~MATCHER
        (send (const nil? :Jobs) :expects (:sym :enqueue))
        MATCHER

        def_node_matcher :mocking_jobs_enqueue_in?, <<~MATCHER
        (send (const nil? :Jobs) :expects (:sym :enqueue_in))
        MATCHER

        def on_send(node)
          if mocking_jobs_enqueue?(node) || mocking_jobs_enqueue_in?(node)
            add_offense(node, message: MSG)
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rubocop-discourse-3.1.0 lib/rubocop/cop/discourse/no_mocking_jobs.rb
rubocop-discourse-3.0.3 lib/rubocop/cop/discourse/no_mocking_jobs.rb
rubocop-discourse-3.0.2 lib/rubocop/cop/discourse/no_mocking_jobs.rb
rubocop-discourse-3.0.1 lib/rubocop/cop/discourse/no_mocking_jobs.rb
rubocop-discourse-3.0 lib/rubocop/cop/discourse/no_mocking_jobs.rb
rubocop-discourse-2.6.0 lib/rubocop/cop/discourse/no_mocking_jobs.rb
rubocop-discourse-2.5.0 lib/rubocop/cop/discourse/no_mocking_jobs.rb
rubocop-discourse-2.4.2 lib/rubocop/cop/discourse/no_mocking_jobs.rb
rubocop-discourse-2.4.1 lib/rubocop/cop/discourse/no_mocking_jobs.rb
rubocop-discourse-2.4.0 lib/rubocop/cop/discourse/no_mocking_jobs.rb
rubocop-discourse-2.3.2 lib/rubocop/cop/discourse/no_mocking_jobs.rb
rubocop-discourse-2.3.1 lib/rubocop/cop/discourse/no_mocking_jobs.rb