Sha256: 4d2ab227a801cd91b7afad7dcc1ee6e7cf7a518c7935d879a702d66b10af1e8f

Contents?: true

Size: 1.17 KB

Versions: 28

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

describe FormatParser::OggParser do
  it 'parses an ogg file' do
    parse_result = subject.call(File.open(__dir__ + '/../fixtures/Ogg/vorbis.ogg', 'rb'))

    expect(parse_result.nature).to eq(:audio)
    expect(parse_result.format).to eq(:ogg)
    expect(parse_result.num_audio_channels).to eq(1)
    expect(parse_result.audio_sample_rate_hz).to eq(16000)
    expect(parse_result.media_duration_seconds).to be_within(0.01).of(2973.95)
  end

  it 'skips a file if it contains more than MAX_POSSIBLE_OGG_PAGE_SIZE bytes of garbage at the end' do
    parse_result = subject.call(File.open(__dir__ + '/../fixtures/Ogg/with_garbage_at_the_end.ogg', 'rb'))
    expect(parse_result).to be_nil
  end

  it "correctly parses an ogg file when a magic string occurs in the page's body" do
    parse_result = subject.call(File.open(__dir__ + '/../fixtures/Ogg/with_confusing_magic_string.ogg', 'rb'))

    expect(parse_result.nature).to eq(:audio)
    expect(parse_result.format).to eq(:ogg)
    expect(parse_result.num_audio_channels).to eq(1)
    expect(parse_result.audio_sample_rate_hz).to eq(8000)
    expect(parse_result.media_duration_seconds).to be_within(0.01).of(0.45)
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
format_parser-0.18.0 spec/parsers/ogg_parser_spec.rb
format_parser-0.17.0 spec/parsers/ogg_parser_spec.rb
format_parser-0.16.1 spec/parsers/ogg_parser_spec.rb
format_parser-0.16.0 spec/parsers/ogg_parser_spec.rb
format_parser-0.15.1 spec/parsers/ogg_parser_spec.rb
format_parser-0.15.0 spec/parsers/ogg_parser_spec.rb
format_parser-0.14.1 spec/parsers/ogg_parser_spec.rb
format_parser-0.14.0 spec/parsers/ogg_parser_spec.rb