Sha256: 757516d2a1c1557a36fa80e4f327997b17971c3c4f5dba52ddd61e554196dbbc

Contents?: true

Size: 1.74 KB

Versions: 10

Compression:

Stored size: 1.74 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.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

10 entries across 10 versions & 1 rubygems

Version Path
m3u8-0.7.0 spec/lib/m3u8/media_item_spec.rb
m3u8-0.6.9 spec/lib/m3u8/media_item_spec.rb
m3u8-0.6.8 spec/lib/m3u8/media_item_spec.rb
m3u8-0.6.7 spec/lib/m3u8/media_item_spec.rb
m3u8-0.6.6 spec/lib/m3u8/media_item_spec.rb
m3u8-0.6.5 spec/lib/m3u8/media_item_spec.rb
m3u8-0.6.4 spec/lib/m3u8/media_item_spec.rb
m3u8-0.6.3 spec/lib/m3u8/media_item_spec.rb
m3u8-0.6.2 spec/lib/m3u8/media_item_spec.rb
m3u8-0.6.1 spec/media_item_spec.rb