lib/rubocop/cop/rspec/shared_examples.rb in rubocop-rspec-1.32.0 vs lib/rubocop/cop/rspec/shared_examples.rb in rubocop-rspec-1.33.0

- old
+ new

@@ -19,18 +19,18 @@ # shared_examples 'foo bar baz' # shared_examples_for 'foo bar baz' # include_examples 'foo bar baz' # class SharedExamples < Cop - def_node_matcher :shared_examples, <<-PATTERN - (send - {(const nil? :RSpec) nil?} - {#{(SharedGroups::ALL + Includes::ALL).node_pattern}} $sym ...) - PATTERN + def_node_matcher :shared_examples, + (SharedGroups::ALL + Includes::ALL).send_pattern def on_send(node) - shared_examples(node) do |ast_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 @@ -42,10 +42,10 @@ end # :nodoc: class Checker MSG = 'Prefer %<prefer>s over `%<current>s` ' \ - 'to titleize shared examples.'.freeze + 'to titleize shared examples.' attr_reader :node def initialize(node) @node = node end