lib/rubocop/cop/rspec/shared_examples.rb in rubocop-rspec-1.41.0 vs lib/rubocop/cop/rspec/shared_examples.rb in rubocop-rspec-1.42.0
- old
+ new
@@ -19,26 +19,23 @@
# shared_examples 'foo bar baz'
# shared_examples_for 'foo bar baz'
# include_examples 'foo bar baz'
#
class SharedExamples < Cop
+ extend AutoCorrector
+
def_node_matcher :shared_examples,
(SharedGroups::ALL + Includes::ALL).send_pattern
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.message)
- end
- end
-
- def autocorrect(node)
- lambda do |corrector|
- checker = Checker.new(node)
- corrector.replace(node.loc.expression, checker.preferred_style)
+ add_offense(checker.node, message: checker.message) do |corrector|
+ corrector.replace(checker.node, checker.preferred_style)
+ end
end
end
# :nodoc:
class Checker