Sha256: 12f2de15a0410eb0e34624e7a554acd0b412ca7eb10e8c8f8195ffe48ee286c0

Contents?: true

Size: 1.23 KB

Versions: 30

Compression:

Stored size: 1.23 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.content_type).to eq('audio/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

30 entries across 30 versions & 1 rubygems

Version Path
format_parser-2.7.0 spec/parsers/ogg_parser_spec.rb
format_parser-2.6.0 spec/parsers/ogg_parser_spec.rb
format_parser-2.5.0 spec/parsers/ogg_parser_spec.rb
format_parser-2.4.5 spec/parsers/ogg_parser_spec.rb
format_parser-2.4.4 spec/parsers/ogg_parser_spec.rb
format_parser-2.4.3 spec/parsers/ogg_parser_spec.rb
format_parser-2.3.0 spec/parsers/ogg_parser_spec.rb
format_parser-2.2.1 spec/parsers/ogg_parser_spec.rb
format_parser-2.2.0 spec/parsers/ogg_parser_spec.rb
format_parser-2.1.0 spec/parsers/ogg_parser_spec.rb
format_parser-2.0.0 spec/parsers/ogg_parser_spec.rb
format_parser-2.0.0.pre.4 spec/parsers/ogg_parser_spec.rb
format_parser-2.0.0.pre.3 spec/parsers/ogg_parser_spec.rb
format_parser-2.0.0.pre.2 spec/parsers/ogg_parser_spec.rb
format_parser-2.0.0.pre spec/parsers/ogg_parser_spec.rb
format_parser-1.7.0 spec/parsers/ogg_parser_spec.rb
format_parser-1.6.0 spec/parsers/ogg_parser_spec.rb
format_parser-1.5.0 spec/parsers/ogg_parser_spec.rb
format_parser-1.4.2 spec/parsers/ogg_parser_spec.rb
format_parser-1.4.1 spec/parsers/ogg_parser_spec.rb