Sha256: ed4ab52f54941ec6ba56e6d4dc5ba1b4d516afe161573933727441e3b49177de

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

RSpec.describe TimeInterval do
  describe '.parse' do
    context 'iso8601 is a valid time and duration' do
      let(:iso8601) { '2007-03-01T13:00:00Z/P1M' }

      it 'should return a TimeWithDuration' do
        expect(TimeInterval.parse(iso8601)).to be_a TimeWithDuration
      end
    end

    context 'iso8601 is a valid time pair' do
      let(:iso8601) { '2007-03-01T13:00:00Z/2008-05-11T15:30:00Z' }

      it 'should return a TimePair' do
        expect(TimeInterval.parse(iso8601)).to be_a TimePair
      end
    end

    context 'iso8601 is a valid repeating interval' do
      let(:iso8601) { 'R/2007-03-01T13:00:00Z/P1M' }

      it 'should return a RepeatingInterval' do
        expect(TimeInterval.parse(iso8601)).to be_a RepeatingInterval
      end
    end

    context 'iso8601 is not an interval' do
      let(:iso8601) { '2007-03-01T13:00:00Z' }

      it 'should return a TimePair with no duration' do
        parsed = TimeInterval.parse(iso8601)

        expect(parsed).to be_a TimePair
        expect(parsed.start_time).to eq parsed.end_time
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
time-interval-0.0.5 spec/lib/time_interval_spec.rb