Sha256: 2bb815dcba640809bb7e907addecbc4fec80cd91818a4e41252fff3a51491df2

Contents?: true

Size: 1.78 KB

Versions: 10

Compression:

Stored size: 1.78 KB

Contents

require 'spec_helper'

describe FitParser::File::Record do
  describe '#read' do
    context 'given a sample definition record' do
      it 'works' do
        record = described_class.new({}, {})
        file = example_file('record/definition_record')
        record.read(file)
        expect(record.header).to be_a(FitParser::File::RecordHeader)
        expect(record.content).to be_a(FitParser::File::Definition)
      end
    end

    context 'given a sample data record with a string non null terminated' do
      context 'string length is equal to field size' do
        it 'works' do
          record = described_class.new({}, {})
          record.read(example_file('record/definition_record_2.fit'))
          definitions = record.definitions
          file = example_file('record/data_record_2.fit')
          record = described_class.new(definitions, {}).read(file)
          expect(record.header).to be_a(FitParser::File::RecordHeader)
          expect(record.content.raw_version).to eql(250)
          expect(record.content.raw_part_number).to eql('123-A1234-00')
        end
      end

      context 'string length is smaller than field size' do
        it 'works' do
          record = described_class.new({}, {})
          record.read(example_file('record/definition_record_2.fit'))
          definitions = record.definitions
          file = example_file('record/data_record_2bis.fit')
          record = described_class.new(definitions, {}).read(file)
          expect(record.header).to be_a(FitParser::File::RecordHeader)
          expect(record.content.raw_version).to eql(251)
          expect(record.content.version).to eql(2.51)
          expect(record.content.raw_part_number).to eql('123-A1234')
          expect(record.content.part_number).to eql('123-A1234')
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
fit_parser-1.0.9 spec/file/record_spec.rb
fit_parser-1.0.8 spec/file/record_spec.rb
fit_parser-1.0.7 spec/file/record_spec.rb
fit_parser-1.0.6 spec/file/record_spec.rb
fit_parser-1.0.5 spec/file/record_spec.rb
fit_parser-1.0.4 spec/file/record_spec.rb
fit_parser-1.0.3 spec/file/record_spec.rb
fit_parser-1.0.2 spec/file/record_spec.rb
fit_parser-1.0.1 spec/file/record_spec.rb
fit_parser-1.0.0 spec/file/record_spec.rb