Sha256: 88b1d812d147f25f833a2fdfbaa2a586eb942b2e2211ba937496f180a811b3da

Contents?: true

Size: 1.77 KB

Versions: 14

Compression:

Stored size: 1.77 KB

Contents

require 'spec_helper'

describe M3u8::SessionDataItem do
  it 'should initialize with hash' do
    hash = { data_id: 'com.test.movie.title', value: 'Test',
             uri: 'http://test', language: 'en' }
    item = M3u8::SessionDataItem.new(hash)
    expect(item.data_id).to eq 'com.test.movie.title'
    expect(item.value).to eq 'Test'
    expect(item.uri).to eq 'http://test'
    expect(item.language).to eq 'en'
  end

  it 'should provide m3u8 format representation' do
    hash = { data_id: 'com.test.movie.title', value: 'Test',
             language: 'en' }
    item = M3u8::SessionDataItem.new(hash)
    output = item.to_s
    expected = %(#EXT-X-SESSION-DATA:DATA-ID="com.test.movie.title",) +
               %(VALUE="Test",LANGUAGE="en")
    expect(output).to eq expected

    hash = { data_id: 'com.test.movie.title', uri: 'http://test',
             language: 'en' }
    item = M3u8::SessionDataItem.new(hash)
    output = item.to_s
    expected = %(#EXT-X-SESSION-DATA:DATA-ID="com.test.movie.title",) +
               %(URI="http://test",LANGUAGE="en")
    expect(output).to eq expected
  end

  it 'should parse m3u8 format into instance' do
    format = %(#EXT-X-SESSION-DATA:DATA-ID="com.test.movie.title",) +
             %(VALUE="Test",LANGUAGE="en")
    item = M3u8::SessionDataItem.parse format
    expect(item.data_id).to eq 'com.test.movie.title'
    expect(item.value).to eq 'Test'
    expect(item.uri).to be_nil
    expect(item.language).to eq 'en'

    format = %(#EXT-X-SESSION-DATA:DATA-ID="com.test.movie.title",) +
             %(URI="http://test",LANGUAGE="en")
    item = M3u8::SessionDataItem.parse format
    expect(item.data_id).to eq 'com.test.movie.title'
    expect(item.value).to be_nil
    expect(item.uri).to eq 'http://test'
    expect(item.language).to eq 'en'
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
m3u8-0.7.0 spec/lib/m3u8/session_data_item_spec.rb
m3u8-0.6.9 spec/lib/m3u8/session_data_item_spec.rb
m3u8-0.6.8 spec/lib/m3u8/session_data_item_spec.rb
m3u8-0.6.7 spec/lib/m3u8/session_data_item_spec.rb
m3u8-0.6.6 spec/lib/m3u8/session_data_item_spec.rb
m3u8-0.6.5 spec/lib/m3u8/session_data_item_spec.rb
m3u8-0.6.4 spec/lib/m3u8/session_data_item_spec.rb
m3u8-0.6.3 spec/lib/m3u8/session_data_item_spec.rb
m3u8-0.6.2 spec/lib/m3u8/session_data_item_spec.rb
m3u8-0.6.1 spec/session_data_item_spec.rb
m3u8-0.5.3 spec/session_data_item_spec.rb
m3u8-0.5.2 spec/session_data_item_spec.rb
m3u8-0.5.1 spec/session_data_item_spec.rb
m3u8-0.5.0 spec/session_data_item_spec.rb