File: range_spec.rb

package info (click to toggle)
ruby-rubocop-ast 0.3.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 892 kB
  • sloc: ruby: 10,886; makefile: 4
file content (22 lines) | stat: -rw-r--r-- 470 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

RSpec.describe RuboCop::AST::Ext::Range do
  let(:source) { <<~RUBY }
    [
      1,
      2
    ]
  RUBY

  let(:node) { parse_source(source).ast }

  describe '#line_span' do
    it 'returns the range of lines a range occupies' do
      expect(node.loc.begin.line_span).to eq 1..1
    end

    it 'accepts an `exclude_end` keyword argument' do
      expect(node.loc.expression.line_span(exclude_end: true)).to eq 1...4
    end
  end
end