Class: RuboCop::Cop::RSpec::DescribeMethod
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::RSpec::DescribeMethod
- Includes:
- RSpec::TopLevelDescribe
- Defined in:
- lib/rubocop/cop/rspec/describe_method.rb
Overview
Checks that the second argument to the top level describe is the tested method name.
Constant Summary collapse
- MESSAGE =
'The second argument to describe should be the method ' \ "being tested. '#instance' or '.class'".freeze
- METHOD_STRING_MATCHER =
/^[\#\.].+/
Instance Method Summary collapse
Methods included from RSpec::TopLevelDescribe
Instance Method Details
#on_top_level_describe(_node, args) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/rubocop/cop/rspec/describe_method.rb', line 28 def on_top_level_describe(_node, args) second_arg = args[1] return unless second_arg && second_arg.type == :str return if METHOD_STRING_MATCHER =~ second_arg.children.first add_offense(second_arg, :expression, MESSAGE) end |