Sha256: cf4fb1adb9205ae84ef568a381ea1b64e01a1d48f63cc277be8cd5d129aa57b1

Contents?: true

Size: 1.75 KB

Versions: 2

Compression:

Stored size: 1.75 KB

Contents

require 'spec_helper'

describe M3u8::MediaItem do
  it 'should provide m3u8 format representation' do
    hash = { type: 'AUDIO', group_id: 'audio-lo', language: 'fre',
             name: 'Francais', autoselect: true, default: false,
             uri: 'frelo/prog_index.m3u8' }
    item = M3u8::MediaItem.new(hash)
    output = item.to_s
    expected = '#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio-lo",LANGUAGE="fre",' \
               'NAME="Francais",AUTOSELECT=YES,DEFAULT=NO,' \
               'URI="frelo/prog_index.m3u8"'
    expect(output).to eq expected

    hash = { type: 'AUDIO', group_id: 'audio-lo', language: 'fre',
             assoc_language: 'spoken', name: 'Francais', autoselect: true,
             default: false, forced: true, uri: 'frelo/prog_index.m3u8' }
    item = M3u8::MediaItem.new(hash)
    output = item.to_s
    expected = '#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio-lo",LANGUAGE="fre",' \
               'ASSOC-LANGUAGE="spoken",NAME="Francais",AUTOSELECT=YES,' \
               'DEFAULT=NO,URI="frelo/prog_index.m3u8",FORCED=YES'
    expect(output).to eq expected
  end

  it 'should parse m3u8 text into instance' do
    format = '#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio-lo",LANGUAGE="fre",' \
             'ASSOC-LANGUAGE="spoken",NAME="Francais",AUTOSELECT=YES,' +
             %("DEFAULT=NO,URI="frelo/prog_index.m3u8",FORCED=YES\n")
    item = M3u8::MediaItem.new
    item.parse format

    expect(item.type).to eq 'AUDIO'
    expect(item.group_id).to eq 'audio-lo'
    expect(item.language).to eq 'fre'
    expect(item.assoc_language).to eq 'spoken'
    expect(item.name).to eq 'Francais'
    expect(item.autoselect).to be true
    expect(item.default).to be false
    expect(item.uri).to eq 'frelo/prog_index.m3u8'
    expect(item.forced).to be true
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
m3u8-0.5.3 spec/media_item_spec.rb
m3u8-0.5.2 spec/media_item_spec.rb