Sha256: c261a24903eaf17ae3473de3ef89ae90a3bd7954a53ebce55331c24afa42d957

Contents?: true

Size: 759 Bytes

Versions: 3

Compression:

Stored size: 759 Bytes

Contents

RSpec.describe Duration do
  describe '.parse' do
    it 'should parse time-only durations correctly' do
      duration = Duration.parse 'PT2H25M'

      expect(duration.months).to eq 0
      expect(duration.hours).to eq 2
      expect(duration.minutes).to eq 25
    end

    it 'should parse date-only durations correctly' do
      duration = Duration.parse 'P1Y2M'

      expect(duration.years).to eq 1
      expect(duration.months).to eq 2
      expect(duration.minutes).to eq 0
    end

    it 'should parse mixed durations correctly' do
      duration = Duration.parse 'P1Y2MT2H25M'

      expect(duration.years).to eq 1
      expect(duration.months).to eq 2
      expect(duration.hours).to eq 2
      expect(duration.minutes).to eq 25
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
time-interval-0.0.5 spec/lib/time_interval/duration_spec.rb
time-interval-0.0.4 spec/lib/time_interval/duration_spec.rb
time-interval-0.0.3 spec/lib/time_interval/duration_spec.rb