diff --git a/lib/rubocop/cop/rspec/around_block.rb b/lib/rubocop/cop/rspec/around_block.rb index 0c992b009..c10d8f183 100644 --- a/lib/rubocop/cop/rspec/around_block.rb +++ b/lib/rubocop/cop/rspec/around_block.rb @@ -69,15 +69,13 @@ def add_no_arg_offense(node) end def check_for_unused_proxy(block, proxy) - name, = *proxy - find_arg_usage(block) do |usage| - return if usage.include?(s(:lvar, name)) + return if usage.include?(s(:lvar, proxy.name)) end add_offense( proxy, - message: format(MSG_UNUSED_ARG, arg: name) + message: format(MSG_UNUSED_ARG, arg: proxy.name) ) end diff --git a/lib/rubocop/cop/rspec/single_argument_message_chain.rb b/lib/rubocop/cop/rspec/single_argument_message_chain.rb index dbc772301..66e6afdd6 100644 --- a/lib/rubocop/cop/rspec/single_argument_message_chain.rb +++ b/lib/rubocop/cop/rspec/single_argument_message_chain.rb @@ -67,11 +67,10 @@ def single_element_array?(node) end def autocorrect_hash_arg(corrector, arg) - key, value = *arg.children.first - - corrector.replace(arg, key_to_arg(key)) + pair = arg.pairs.first + corrector.replace(arg, key_to_arg(pair.key)) corrector.insert_after(arg.parent.loc.end, - ".and_return(#{value.source})") + ".and_return(#{pair.value.source})") end def autocorrect_array_arg(corrector, arg)