lib/rubocop/cop/rspec/hook_argument.rb in rubocop-rspec-2.12.1 vs lib/rubocop/cop/rspec/hook_argument.rb in rubocop-rspec-2.13.0

- old
+ new

@@ -55,24 +55,27 @@ # # # good # before(:example) do # # ... # end + # class HookArgument < Base extend AutoCorrector include ConfigurableEnforcedStyle IMPLICIT_MSG = 'Omit the default `%<scope>p` argument for RSpec hooks.' EXPLICIT_MSG = 'Use `%<scope>p` for RSpec hooks.' # @!method scoped_hook(node) def_node_matcher :scoped_hook, <<-PATTERN - (block $(send _ #Hooks.all (sym ${:each :example})) ...) + ({block numblock} $(send _ #Hooks.all (sym ${:each :example})) ...) PATTERN # @!method unscoped_hook(node) - def_node_matcher :unscoped_hook, '(block $(send _ #Hooks.all) ...)' + def_node_matcher :unscoped_hook, <<-PATTERN + ({block numblock} $(send _ #Hooks.all) ...) + PATTERN def on_block(node) hook(node) do |method_send, scope_name| return correct_style_detected if scope_name.equal?(style) return check_implicit(method_send) unless scope_name @@ -83,9 +86,11 @@ scope = implicit_style? ? '' : "(#{style.inspect})" corrector.replace(argument_range(method_send), scope) end end end + + alias on_numblock on_block private def check_implicit(method_send) style_detected(:implicit)