Sha256: b1dea5b9271be47cc7880893b040f7a5e2b24cb0da8491fdfd8ee2ad050f4dc1

Contents?: true

Size: 969 Bytes

Versions: 3

Compression:

Stored size: 969 Bytes

Contents

require 'time-interval'

RSpec.describe Transform::TimeInterval do
  let(:interval_str) { '2007-03-01T13:00:00Z/P1M' }
  let(:interval) { TimeInterval.parse interval_str }

  let(:repeating_str) { 'R2/2007-03-01T13:00:00Z/P1M' }
  let(:repeating) { TimeInterval.parse repeating_str }

  describe '.deserialize' do
    it 'should transform strings to a TimeInterval' do
      deserialized = Transform::TimeInterval.deserialize(interval_str)

      expect(deserialized.start_time).to eq interval.start_time
      expect(deserialized.end_time).to eq interval.end_time
    end

    it 'should return nil if not a string or TimeInterval' do
      expect(Transform::TimeInterval.deserialize(true)).to eq nil
    end
  end

  describe '.serialize' do
    it 'should transform the value to a string' do
      expect(Transform::TimeInterval.serialize(interval)).to eq interval_str
      expect(Transform::TimeInterval.serialize(repeating)).to eq repeating_str
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
aggro-0.0.4 spec/lib/aggro/transform/time_interval_spec.rb
aggro-0.0.3 spec/lib/aggro/transform/time_interval_spec.rb
aggro-0.0.2 spec/lib/aggro/transform/time_interval_spec.rb