Class: RuboCop::Cop::RSpec::SharedExamples
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/rspec/shared_examples.rb
Overview
Enforces use of string to titleize shared examples.
Defined Under Namespace
Classes: Checker
Instance Method Summary collapse
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_send(node) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rubocop/cop/rspec/shared_examples.rb', line 32 def on_send(node) shared_examples(node) do ast_node = node.first_argument next unless ast_node&.sym_type? checker = Checker.new(ast_node) add_offense(checker.node, message: checker.) do |corrector| corrector.replace(checker.node, checker.preferred_style) end end end |
#shared_examples(node) ⇒ Object
27 28 29 30 |
# File 'lib/rubocop/cop/rspec/shared_examples.rb', line 27 def_node_matcher :shared_examples, send_pattern( '{#SharedGroups.all #Includes.all}' ) |