Module: RuboCop::Cop::RSpec::LocationHelp

Defined in:
lib/rubocop/cop/rspec/mixin/location_help.rb

Overview

Helper methods to location.

Class Method Summary collapse

Class Method Details

.arguments_with_whitespace(node) ⇒ Parser::Source::Range

Examples:

foo 1, 2
   ^^^^^

Parameters:

  • node (RuboCop::AST::SendNode)

Returns:

  • (Parser::Source::Range)


15
16
17
18
19
# 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) ⇒ Parser::Source::Range

Examples:

foo { bar }
   ^^^^^^^^

Parameters:

  • node (RuboCop::AST::SendNode)

Returns:

  • (Parser::Source::Range)


26
27
28
29
30
31
32
33
# 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