module RuboCop::Cop::RSpec::LocationHelp

Helper methods to location.

Public Instance Methods

arguments_with_whitespace(node) click to toggle source

@param node [RuboCop::AST::SendNode] @return [Parser::Source::Range] @example

foo 1, 2
   ^^^^^
# File lib/rubocop/cop/rspec/mixin/location_help.rb, line 15
def arguments_with_whitespace(node)
  node.loc.selector.end.with(
    end_pos: node.source_range.end_pos
  )
end
block_with_whitespace(node) click to toggle source

@param node [RuboCop::AST::SendNode] @return [Parser::Source::Range] @example

foo { bar }
   ^^^^^^^^
# File lib/rubocop/cop/rspec/mixin/location_help.rb, line 26
def block_with_whitespace(node)
  return unless (parent = node.parent)
  return unless parent.block_type?

  node.source_range.end.with(
    end_pos: parent.source_range.end_pos
  )
end