module RuboCop::RSpec::FinalEndLocation

Helps find the true end location of nodes which might contain heredocs.

Public Instance Methods

final_end_location(start_node) click to toggle source
# File lib/rubocop/rspec/final_end_location.rb, line 7
def final_end_location(start_node)
  heredoc_endings =
    start_node.each_node(:str, :dstr, :xstr)
      .select(&:heredoc?)
      .map { |node| node.loc.heredoc_end }

  [start_node.loc.end, *heredoc_endings].max_by(&:line)
end