Sha256: 73bf9e08acf55769fe37b7d084c2539fe949c1230ebf0a7a42da8c8b149c8858

Contents?: true

Size: 932 Bytes

Versions: 2

Compression:

Stored size: 932 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Range, '#to_inclusive' do
  subject { object.to_inclusive }

  let(:object) { described_class.new(range_start, range_end, exclusive) }

  context 'on an exclusive Range' do
    let(:exclusive) { true }

    context 'with values that responds to #pred' do
      let(:range_start) { 1 }
      let(:range_end)   { 3 }

      it { should be_instance_of(described_class) }

      it 'returns an inclusive Range' do
        should eql(described_class.new(1, 2))
      end
    end

    context 'with values that do not respond to #pred' do
      let(:range_start) { 'a' }
      let(:range_end)   { 'z' }

      specify { expect { subject }.to raise_error(NoMethodError) }
    end
  end

  context 'on an inclusive Range' do
    let(:range_start) { 1     }
    let(:range_end)   { 2     }
    let(:exclusive)   { false }

    it 'returns self' do
      should be(object)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
axiom-0.2.0 spec/unit/range/to_inclusive_spec.rb
axiom-0.1.1 spec/unit/range/to_inclusive_spec.rb