Sha256: 134fe4a9b2c89cdd07c8e9a9db44f3cd84e21ec4c8c6c0aa5b15c3389550e2ec

Contents?: true

Size: 1.52 KB

Versions: 15

Compression:

Stored size: 1.52 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.call(File.open(fpath, 'rb'))

    expect(parsed).not_to be_nil

    expect(parsed.nature).to eq(:audio)
    expect(parsed.format).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.call(File.open(fpath, 'rb'))

    expect(parsed).not_to be_nil

    expect(parsed.nature).to eq(:audio)
    expect(parsed.format).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.call(File.open(fpath, 'rb'))

    expect(parsed).not_to be_nil

    expect(parsed.nature).to eq(:audio)
    expect(parsed.format).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

15 entries across 15 versions & 1 rubygems

Version Path
format_parser-0.9.0 spec/parsers/mp3_parser_spec.rb
format_parser-0.8.0 spec/parsers/mp3_parser_spec.rb
format_parser-0.7.0 spec/parsers/mp3_parser_spec.rb
format_parser-0.6.0 spec/parsers/mp3_parser_spec.rb
format_parser-0.5.2 spec/parsers/mp3_parser_spec.rb
format_parser-0.5.1 spec/parsers/mp3_parser_spec.rb
format_parser-0.5.0 spec/parsers/mp3_parser_spec.rb
format_parser-0.4.0 spec/parsers/mp3_parser_spec.rb
format_parser-0.3.5 spec/parsers/mp3_parser_spec.rb
format_parser-0.3.4 spec/parsers/mp3_parser_spec.rb
format_parser-0.3.3 spec/parsers/mp3_parser_spec.rb
format_parser-0.3.2 spec/parsers/mp3_parser_spec.rb
format_parser-0.3.1 spec/parsers/mp3_parser_spec.rb
format_parser-0.3.0 spec/parsers/mp3_parser_spec.rb
format_parser-0.2.0 spec/parsers/mp3_parser_spec.rb