Sha256: c146b608c827403c4b1c5a7d09a876147aaebd48dd0b3302d76bb31b3a96772b

Contents?: true

Size: 1.7 KB

Versions: 4

Compression:

Stored size: 1.7 KB

Contents

# frozen_string_literal: true
require 'spec_helper'

describe M3u8::KeyItem do
  it 'should initialize with hash' do
    hash = { method: 'AES-128', uri: 'http://test.key',
             iv: 'D512BBF', key_format: 'identity',
             key_format_versions: '1/3' }
    item = M3u8::KeyItem.new(hash)
    expect(item.method).to eq 'AES-128'
    expect(item.uri).to eq 'http://test.key'
    expect(item.iv).to eq 'D512BBF'
    expect(item.key_format).to eq 'identity'
    expect(item.key_format_versions).to eq '1/3'
  end

  it 'should provide m3u8 format representation' do
    hash = { method: 'AES-128', uri: 'http://test.key',
             iv: 'D512BBF', key_format: 'identity',
             key_format_versions: '1/3' }
    item = M3u8::KeyItem.new(hash)
    expected = %(#EXT-X-KEY:METHOD=AES-128,URI="http://test.key",) +
               %(IV=D512BBF,KEYFORMAT="identity",KEYFORMATVERSIONS="1/3")
    expect(item.to_s).to eq expected

    hash = { method: 'AES-128', uri: 'http://test.key' }
    item = M3u8::KeyItem.new(hash)
    expected = %(#EXT-X-KEY:METHOD=AES-128,URI="http://test.key")
    expect(item.to_s).to eq expected

    hash = { method: 'NONE' }
    item = M3u8::KeyItem.new(hash)
    expected = '#EXT-X-KEY:METHOD=NONE'
    expect(item.to_s).to eq expected
  end

  it 'should parse m3u8 format into instance' do
    format = %(#EXT-X-KEY:METHOD=AES-128,URI="http://test.key",) +
             %(IV=D512BBF,KEYFORMAT="identity",KEYFORMATVERSIONS="1/3")
    item = M3u8::KeyItem.parse format
    expect(item.method).to eq 'AES-128'
    expect(item.uri).to eq 'http://test.key'
    expect(item.iv).to eq 'D512BBF'
    expect(item.key_format).to eq 'identity'
    expect(item.key_format_versions).to eq '1/3'
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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