1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
# frozen_string_literal: true
module RuboCop
module Cop
module RSpec
class AggregateExamples < ::RuboCop::Cop::Cop
# @internal Support methods for keeping newlines around examples.
module LineRangeHelpers
include RangeHelp
private
def range_for_replace(examples)
range = range_by_whole_lines(examples.first.source_range,
include_final_newline: true)
next_range = range_by_whole_lines(examples[1].source_range)
if adjacent?(range, next_range)
range.resize(range.length + 1)
else
range
end
end
def adjacent?(range, another_range)
range.end_pos + 1 == another_range.begin_pos
end
end
end
end
end
end
|