Sha256: e96d5e94cc8c14ea2c2133a237f7e55718147648aa9eac0aca2f9530dddcc8f4

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true
require 'spec_helper'

describe M3u8::MapItem do
  it 'should provide m3u8 format representation' do
    hash = { uri: 'frelo/prog_index.m3u8',
             byterange: { length: 4500, start: 600 } }
    item = M3u8::MapItem.new(hash)
    output = item.to_s
    expected = '#EXT-X-MAP:URI="frelo/prog_index.m3u8",' \
               'BYTERANGE="4500@600"'
    expect(output).to eq expected

    hash = { uri: 'frehi/prog_index.m3u8' }
    item = M3u8::MapItem.new(hash)
    output = item.to_s
    expected = '#EXT-X-MAP:URI="frehi/prog_index.m3u8"'
    expect(output).to eq expected
  end

  it 'should parse m3u8 text into instance' do
    input = '#EXT-X-MAP:URI="frelo/prog_index.m3u8",' \
            'BYTERANGE="3500@300"'

    item = M3u8::MapItem.parse(input)

    expect(item.uri).to eq 'frelo/prog_index.m3u8'
    expect(item.byterange.length).to eq 3500
    expect(item.byterange.start).to eq 300

    input = '#EXT-X-MAP:URI="frelo/prog_index.m3u8"'

    item = M3u8::MapItem.parse(input)

    expect(item.uri).to eq 'frelo/prog_index.m3u8'
    expect(item.byterange).to be_nil
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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