Sha256: 13a066aba043d53b4644df0450d14b33c7d02512575a3bac5e43ca188cae06f7

Contents?: true

Size: 1.8 KB

Versions: 4

Compression:

Stored size: 1.8 KB

Contents

# frozen_string_literal: true
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

4 entries across 4 versions & 1 rubygems

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