Sha256: 7435c5c68d0488f4bf5f858f48b35530ab14aaa4a9090e5952e9f65458aea4b3

Contents?: true

Size: 1.01 KB

Versions: 5

Compression:

Stored size: 1.01 KB

Contents

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

      it 'should create a TimePair' do
        result = TimePair.parse iso8601

        expect(result).to be_a TimePair
      end

      it 'should have correct start_time' do
        result = TimePair.parse iso8601

        expect(result.start_time).to eq Time.parse('2007-03-01T13:00:00Z')
      end

      it 'should have correct end_time' do
        result = TimePair.parse iso8601

        expect(result.end_time).to eq Time.parse('2008-05-11T15:30:00Z')
      end
    end
  end

  describe '#iso8601' do
    let(:first_time) { Time.parse('2007-03-01T13:00:00Z') }
    let(:last_time) { Time.parse('2008-05-11T15:30:00Z') }
    let(:time_pair) { TimePair.new first_time, last_time }

    it 'should return a valid iso8601 time pair' do
      expected = '2007-03-01T13:00:00Z/2008-05-11T15:30:00Z'

      expect(time_pair.iso8601).to eq expected
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
time-interval-0.0.5 spec/lib/time_interval/time_pair_spec.rb
time-interval-0.0.4 spec/lib/time_interval/time_pair_spec.rb
time-interval-0.0.3 spec/lib/time_interval/time_pair_spec.rb
time-interval-0.0.2 spec/lib/time_interval/time_pair_spec.rb
time-interval-0.0.1 spec/lib/time_interval/time_pair_spec.rb