Class: RuboCop::Cop::RSpec::RepeatedExampleGroupDescription
- Includes:
- SkipOrPending
- Defined in:
- lib/rubocop/cop/rspec/repeated_example_group_description.rb
Overview
Check for repeated example group descriptions.
Constant Summary collapse
- MSG =
'Repeated %<group>s block description on line(s) %<loc>s'
Instance Method Summary collapse
- #doc_string_and_metadata(node) ⇒ Object
- #empty_description?(node) ⇒ Object
- #on_begin(node) ⇒ Object
- #several_example_groups?(node) ⇒ Object
Methods included from SkipOrPending
#skip_or_pending_inside_block?, #skipped_in_metadata?
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
#doc_string_and_metadata(node) ⇒ Object
56 57 58 |
# File 'lib/rubocop/cop/rspec/repeated_example_group_description.rb', line 56 def_node_matcher :doc_string_and_metadata, <<~PATTERN (block (send _ _ $_ $...) ...) PATTERN |
#empty_description?(node) ⇒ Object
61 |
# File 'lib/rubocop/cop/rspec/repeated_example_group_description.rb', line 61 def_node_matcher :empty_description?, '(block (send _ _) ...)' |
#on_begin(node) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/rubocop/cop/rspec/repeated_example_group_description.rb', line 63 def on_begin(node) return unless several_example_groups?(node) repeated_group_descriptions(node).each do |group, repeats| add_offense(group, message: (group, repeats)) end end |
#several_example_groups?(node) ⇒ Object
51 52 53 |
# File 'lib/rubocop/cop/rspec/repeated_example_group_description.rb', line 51 def_node_matcher :several_example_groups?, <<~PATTERN (begin <#example_group? #example_group? ...>) PATTERN |