Sha256: f8ff9ed109a888c208c31064fe9d0796fb95a2d68b062751505786d84656b33e

Contents?: true

Size: 888 Bytes

Versions: 3

Compression:

Stored size: 888 Bytes

Contents

# frozen_string_literal: true

describe Rake::Funnel::Support::BinaryVersionReader do
  def binary_version(*version_parts)
    version = version_parts.map { |p| p.to_s + "\0" }.join(".\0")
    "F\0i\0l\0e\0V\0e\0r\0s\0i\0o\0n" + "\0" * 3 + version + "\0" * 3
  end

  let(:file) { 'some assembly' }

  before do
    allow(File).to receive(:binread).with(file).and_return(contents)
  end

  describe 'version can be read' do
    let(:version) { %w(1 2 3 4) }
    let(:contents) { "binary #{binary_version(*version)} binary" }

    it 'should yield all parts' do
      expect(described_class.read_from(file).file_version).to eq(version.join('.'))
    end
  end

  describe 'version cannot be read' do
    let(:contents) { 'this does not contain a version number' }

    it 'should yield empty VersionInfo' do
      expect(described_class.read_from(file).to_h).to be_empty
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rake-funnel-0.24.0 spec/rake/funnel/support/binary_version_reader_spec.rb
rake-funnel-0.23.0 spec/rake/funnel/support/binary_version_reader_spec.rb
rake-funnel-0.22.3 spec/rake/funnel/support/binary_version_reader_spec.rb