Sha256: 761629cfe057703e5d05af714188145fae28a46014d5a617ba869da69432617e

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true
require 'spec_helper'

describe M3u8::PlaybackStart do
  describe '#intialize' do
    it 'assigns attributes' do
      start = described_class.new(time_offset: -12.9, precise: true)
      expect(start.time_offset).to eq(-12.9)
      expect(start.precise).to be true
    end
  end

  describe '#parse' do
    it 'parses tag with all attributes' do
      start = described_class.new
      tag = '#EXT-X-START:TIME-OFFSET=20.0,PRECISE=YES'
      start.parse(tag)

      expect(start.time_offset).to eq(20.0)
      expect(start.precise).to be true
    end

    it 'parses tag without optional attributes' do
      start = described_class.new
      tag = '#EXT-X-START:TIME-OFFSET=-12.9'
      start.parse(tag)

      expect(start.time_offset).to eq(-12.9)
      expect(start.precise).to be_nil
    end
  end

  describe '#to_s' do
    it 'returns tag with attributes' do
      start = described_class.new(time_offset: 9.2, precise: true)
      tag = start.to_s

      expect(tag).to eq('#EXT-X-START:TIME-OFFSET=9.2,PRECISE=YES')
    end

    it 'returns tag without optional attributes' do
      start = described_class.new(time_offset: 9.2)
      tag = start.to_s

      expect(tag).to eq('#EXT-X-START:TIME-OFFSET=9.2')
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
m3u8-0.8.2 spec/lib/m3u8/playback_start_spec.rb
m3u8-0.8.1 spec/lib/m3u8/playback_start_spec.rb
m3u8-0.8.0 spec/lib/m3u8/playback_start_spec.rb
m3u8-0.7.1 spec/lib/m3u8/playback_start_spec.rb