lib/rubocop/cop/rspec/yield.rb in rubocop-rspec-1.32.0 vs lib/rubocop/cop/rspec/yield.rb in rubocop-rspec-1.33.0
- old
+ new
@@ -12,11 +12,11 @@
# # good
# expect(foo).to be(:bar).and_yield(1)
class Yield < Cop
include RangeHelp
- MSG = 'Use `.and_yield`.'.freeze
+ MSG = 'Use `.and_yield`.'
def_node_search :method_on_stub?, '(send nil? :receive ...)'
def_node_matcher :block_arg, '(args (blockarg $_))'
@@ -50,12 +50,10 @@
block_call?(node, block)
end
end
def block_range(node)
- block_start = node.loc.begin.begin_pos
- block_end = node.loc.end.end_pos
- range_between(block_start, block_end)
+ node.loc.begin.with(end_pos: node.loc.end.end_pos)
end
def generate_replacement(node)
if node.begin_type?
node.children.map { |child| convert_block_to_yield(child) }.join