lib/rubocop/rspec/language.rb in rubocop-rspec-2.18.1 vs lib/rubocop/rspec/language.rb in rubocop-rspec-2.19.0

- old
+ new

@@ -18,55 +18,64 @@ class << self attr_accessor :config end # @!method rspec?(node) - def_node_matcher :rspec?, '{(const {nil? cbase} :RSpec) nil?}' + def_node_matcher :rspec?, '{#explicit_rspec? nil?}' + # @!method explicit_rspec?(node) + def_node_matcher :explicit_rspec?, '(const {nil? cbase} :RSpec)' + # @!method example_group?(node) - def_node_matcher :example_group?, block_pattern('#ExampleGroups.all') + def_node_matcher :example_group?, <<~PATTERN + ({block numblock} (send #rspec? #ExampleGroups.all ...) ...) + PATTERN # @!method shared_group?(node) - def_node_matcher :shared_group?, block_pattern('#SharedGroups.all') + def_node_matcher :shared_group?, + '(block (send #rspec? #SharedGroups.all ...) ...)' # @!method spec_group?(node) - def_node_matcher :spec_group?, - block_pattern('{#SharedGroups.all #ExampleGroups.all}') + def_node_matcher :spec_group?, <<~PATTERN + ({block numblock} (send #rspec? + {#SharedGroups.all #ExampleGroups.all} + ...) ...) + PATTERN # @!method example_group_with_body?(node) def_node_matcher :example_group_with_body?, <<-PATTERN - (block #{send_pattern('#ExampleGroups.all')} args !nil?) + (block (send #rspec? #ExampleGroups.all ...) args !nil?) PATTERN # @!method example?(node) - def_node_matcher :example?, block_pattern('#Examples.all') + def_node_matcher :example?, '(block (send nil? #Examples.all ...) ...)' # @!method hook?(node) def_node_matcher :hook?, <<-PATTERN - { - #{block_pattern('#Hooks.all')} - #{numblock_pattern('#Hooks.all')} - } + { + (numblock (send nil? #Hooks.all ...) ...) + (block (send nil? #Hooks.all ...) ...) + } PATTERN # @!method let?(node) def_node_matcher :let?, <<-PATTERN { - #{block_pattern('#Helpers.all')} - (send #rspec? #Helpers.all _ block_pass) + (block (send nil? #Helpers.all ...) ...) + (send nil? #Helpers.all _ block_pass) } PATTERN # @!method include?(node) def_node_matcher :include?, <<-PATTERN { - #{send_pattern('#Includes.all')} - #{block_pattern('#Includes.all')} + (block (send nil? #Includes.all ...) ...) + (send nil? #Includes.all ...) } PATTERN # @!method subject?(node) - def_node_matcher :subject?, block_pattern('#Subjects.all') + def_node_matcher :subject?, '(block (send nil? #Subjects.all ...) ...)' module ExampleGroups # :nodoc: class << self def all(element) regular(element) ||