Sha256: 139185c0650edea96883a4c985431112ee031a611c5dedd27b257a21e14e9ba9

Contents?: true

Size: 772 Bytes

Versions: 1

Compression:

Stored size: 772 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module RSpec
      # Avoid describing symbols.
      #
      # @example
      #   # bad
      #   describe :my_method do
      #     # ...
      #   end
      #
      #   # good
      #   describe '#my_method' do
      #     # ...
      #   end
      #
      # @see https://github.com/rspec/rspec-core/issues/1610
      class DescribeSymbol < Base
        MSG = 'Avoid describing symbols.'
        RESTRICT_ON_SEND = %i[describe].freeze

        def_node_matcher :describe_symbol?, <<-PATTERN
          (send #rspec? :describe $sym ...)
        PATTERN

        def on_send(node)
          describe_symbol?(node) do |match|
            add_offense(match)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-rspec-2.2.0 lib/rubocop/cop/rspec/describe_symbol.rb