Sha256: 83b7b2b769aff2afb7b8ae02569eb38da7becdd79fd0671029808868525eff21

Contents?: true

Size: 768 Bytes

Versions: 4

Compression:

Stored size: 768 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 < Cop
        MSG = 'Avoid describing symbols.'.freeze

        def_node_matcher :describe_symbol?, <<-PATTERN
          (send {(const nil? :RSpec) nil?} :describe $sym ...)
        PATTERN

        def on_send(node)
          describe_symbol?(node) do |match|
            add_offense(match, location: :expression)
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-rspec-1.21.0 lib/rubocop/cop/rspec/describe_symbol.rb
rubocop-rspec-1.20.1 lib/rubocop/cop/rspec/describe_symbol.rb
rubocop-rspec-1.20.0 lib/rubocop/cop/rspec/describe_symbol.rb
rubocop-rspec-1.19.0 lib/rubocop/cop/rspec/describe_symbol.rb