Class: RuboCop::Cop::RSpec::DescribeMethod
- Includes:
- TopLevelGroup
- 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'."
Instance Method Summary collapse
Methods included from TopLevelGroup
#on_new_investigation, #top_level_groups
Methods inherited from Base
inherited, #on_new_investigation
Methods included from RSpec::Language::NodePattern
Methods included from RSpec::Language
#example?, #example_group?, #example_group_with_body?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?
Instance Method Details
#on_top_level_group(node) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/rubocop/cop/rspec/describe_method.rb', line 32 def on_top_level_group(node) second_argument = second_argument(node) return unless second_argument return if second_argument.str_content.start_with?('#', '.') add_offense(second_argument) end |
#second_argument(node) ⇒ Object
26 27 28 29 30 |
# File 'lib/rubocop/cop/rspec/describe_method.rb', line 26 def_node_matcher :second_argument, <<~PATTERN (block (send #rspec? :describe _first_argument $(str _) ...) ... ) PATTERN |