Class: RuboCop::Cop::RSpec::NestedGroups
- Includes:
- TopLevelGroup
- Defined in:
- lib/rubocop/cop/rspec/nested_groups.rb
Overview
Checks for nested example groups.
This cop is configurable using the ‘Max` option and supports `–auto-gen-config`.
Constant Summary collapse
- MSG =
'Maximum example group nesting exceeded [%<total>d/%<max>d].'
- DEPRECATED_MAX_KEY =
'MaxNesting'
- DEPRECATION_WARNING =
"Configuration key `#{DEPRECATED_MAX_KEY}` for #{cop_name} is " \ 'deprecated in favor of `Max`. Please use that instead.'
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
#example?, #example_group?, #example_group_with_body?, #explicit_rspec?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?
Instance Method Details
#on_top_level_group(node) ⇒ Object
107 108 109 110 111 112 113 114 115 |
# File 'lib/rubocop/cop/rspec/nested_groups.rb', line 107 def on_top_level_group(node) find_nested_example_groups(node) do |example_group, nesting| self.max = nesting add_offense( example_group.send_node, message: (nesting) ) end end |