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 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
# frozen_string_literal: true
RSpec.describe RuboCop::AST::RangeNode do
let(:range_node) { parse_source(source).ast }
describe '.new' do
context 'with an inclusive range' do
let(:source) do
'1..2'
end
it { expect(range_node.is_a?(described_class)).to be(true) }
it { expect(range_node.range_type?).to be(true) }
end
context 'with an exclusive range' do
let(:source) do
'1...2'
end
it { expect(range_node.is_a?(described_class)).to be(true) }
it { expect(range_node.range_type?).to be(true) }
end
context 'with an infinite range' do
let(:ruby_version) { 2.6 }
let(:source) do
'1..'
end
it { expect(range_node.is_a?(described_class)).to be(true) }
it { expect(range_node.range_type?).to be(true) }
end
context 'with a beignless range' do
let(:ruby_version) { 2.7 }
let(:source) do
'..42'
end
it { expect(range_node.is_a?(described_class)).to be(true) }
it { expect(range_node.range_type?).to be(true) }
end
end
end
|