Sha256: d6148e88f011998217ec8e610fbfe06196cd9c77a55b472020e52dcf95b1d6db

Contents?: true

Size: 1.58 KB

Versions: 2

Compression:

Stored size: 1.58 KB

Contents

require 'spec_helper'

describe FormatParser::MP3Parser do
  it 'decodes and estimates duration for a VBR MP3' do
    fpath = fixtures_dir + '/MP3/atc_fixture_vbr.mp3'
    parsed = subject.information_from_io(File.open(fpath, 'rb'))

    expect(parsed).not_to be_nil

    expect(parsed.file_nature).to eq(:audio)
    expect(parsed.file_type).to eq(:mp3)
    expect(parsed.num_audio_channels).to eq(2)
    expect(parsed.audio_sample_rate_hz).to eq(44100)
    expect(parsed.intrinsics).not_to be_nil
    expect(parsed.media_duration_seconds).to be_within(0.1).of(0.836)
  end

  it 'decodes and estimates duration for a CBR MP3' do
    fpath = fixtures_dir + '/MP3/atc_fixture_cbr.mp3'
    parsed = subject.information_from_io(File.open(fpath, 'rb'))

    expect(parsed).not_to be_nil

    expect(parsed.file_nature).to eq(:audio)
    expect(parsed.file_type).to eq(:mp3)
    expect(parsed.num_audio_channels).to eq(2)
    expect(parsed.audio_sample_rate_hz).to eq(44100)
    expect(parsed.intrinsics).not_to be_nil
    expect(parsed.media_duration_seconds).to be_within(0.1).of(0.81)
  end

  it 'parses the Cassy MP3' do
    fpath = fixtures_dir + '/MP3/Cassy.mp3'
    parsed = subject.information_from_io(File.open(fpath, 'rb'))

    expect(parsed).not_to be_nil

    expect(parsed.file_nature).to eq(:audio)
    expect(parsed.file_type).to eq(:mp3)
    expect(parsed.num_audio_channels).to eq(2)
    expect(parsed.audio_sample_rate_hz).to eq(44100)
    expect(parsed.intrinsics).not_to be_nil
    expect(parsed.media_duration_seconds).to be_within(0.1).of(1102.46)

    expect(parsed.intrinsics).not_to be_nil
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
format_parser-0.1.7 spec/parsers/mp3_parser_spec.rb
format_parser-0.1.6 spec/parsers/mp3_parser_spec.rb