Class: RuboCop::Cop::RSpec::DescribeSymbol

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/rspec/describe_symbol.rb

Overview

Avoid describing symbols.

Examples:

# bad
describe :my_method do
  # ...
end

# good
describe '#my_method' do
  # ...
end

See Also:

Constant Summary collapse

MSG =
'Avoid describing symbols.'
RESTRICT_ON_SEND =
%i[describe].freeze

Instance Method Summary collapse

Methods inherited from Base

inherited, #on_new_investigation

Methods included from RSpec::Language

#example?, #example_group?, #example_group_with_body?, #explicit_rspec?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?

Instance Method Details

#describe_symbol?(node) ⇒ Object



25
26
27
# File 'lib/rubocop/cop/rspec/describe_symbol.rb', line 25

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

#on_send(node) ⇒ Object



29
30
31
32
33
# File 'lib/rubocop/cop/rspec/describe_symbol.rb', line 29

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