Sha256: 96eb897429976663b89682c7414be11e998ba3adb7aed72470d30b34108b5d42

Contents?: true

Size: 731 Bytes

Versions: 6

Compression:

Stored size: 731 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) { |match| add_offense(match, :expression) }
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubocop-rspec-1.18.0 lib/rubocop/cop/rspec/describe_symbol.rb
rubocop-rspec-1.17.1 lib/rubocop/cop/rspec/describe_symbol.rb
rubocop-rspec-1.17.0 lib/rubocop/cop/rspec/describe_symbol.rb
rubocop-rspec-1.16.0 lib/rubocop/cop/rspec/describe_symbol.rb
rubocop-rspec-1.15.1 lib/rubocop/cop/rspec/describe_symbol.rb
rubocop-rspec-1.15.0 lib/rubocop/cop/rspec/describe_symbol.rb