Class: RuboCop::Cop::RSpec::DescribeMethod
- Includes:
- RSpec::TopLevelDescribe, RSpec::Util
- Defined in:
- lib/rubocop/cop/rspec/describe_method.rb
Overview
Checks that the second argument to ‘describe` specifies a method.
Constant Summary collapse
- MSG =
'The second argument to describe should be the method '\ "being tested. '#instance' or '.class'.".freeze
- METHOD_STRING_MATCHER =
/\A[\#\.].+/
Constants included from RSpec::Util
Constants inherited from Cop
Constants included from RSpec::Language
Instance Method Summary collapse
Methods included from RSpec::Util
Methods included from RSpec::TopLevelDescribe
Methods inherited from Cop
Instance Method Details
#on_top_level_describe(_node, _, second_arg) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/rubocop/cop/rspec/describe_method.rb', line 28 def on_top_level_describe(_node, (_, second_arg)) return unless second_arg && second_arg.str_type? return if METHOD_STRING_MATCHER =~ one(second_arg.children) add_offense(second_arg, location: :expression) end |