Sha256: 505440d8423e8f5934510439a341d8bfb95dbd5f650b51e038fb404c234e0113

Contents?: true

Size: 1.28 KB

Versions: 12

Compression:

Stored size: 1.28 KB

Contents

require 'spec_helper'

describe Dockly::Util::Git do
  describe '#repo' do
    it 'returns the repo for the current directory' do
      expect(subject.repo.git_work_tree).to eq(File.expand_path('.'))
    end
  end

  describe '#sha' do
    it 'returns a sha for the head object' do
      expect(subject.sha).to eq(`git rev-parse HEAD`.chomp)
    end
  end

  describe '#archive' do
    let(:io) { StringIO.new }
    let(:prefix) { '/gem/dockly' }
    let(:reader) { Gem::Package::TarReader.new(io.tap(&:rewind)) }

    it 'archives the current directory into the given IO' do
      subject.archive(subject.sha, prefix, io)
      reader.each do |entry|
        if entry.full_name == 'pax_global_header'
          expect(entry.header.typeflag).to eq('g')
        else
          expect(entry.full_name).to start_with(prefix)
          orig = entry.full_name.gsub(/\A#{prefix}/, '.')
          expect(File.exist?(orig)).to be_true
          expect(entry.read).to eq(File.read(orig)) if orig.end_with?('.rb')
        end
      end
    end

    context 'with a really long prefix' do
      let(:prefix) { '/' + ('a' * 255) }
      it 'exhibits the tar extended headers' do
        subject.archive(subject.sha, prefix, io)
        expect(io.string.include?("path=#{prefix}")).to be true
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
dockly-4.4.1 spec/dockly/util/git_spec.rb
dockly-4.4.0 spec/dockly/util/git_spec.rb
dockly-4.3.0 spec/dockly/util/git_spec.rb
dockly-4.2.0 spec/dockly/util/git_spec.rb
dockly-4.1.0 spec/dockly/util/git_spec.rb
dockly-4.0.0 spec/dockly/util/git_spec.rb
dockly-3.4.1 spec/dockly/util/git_spec.rb
dockly-3.4.0 spec/dockly/util/git_spec.rb
dockly-3.3.0 spec/dockly/util/git_spec.rb
dockly-3.2.0.pre.1 spec/dockly/util/git_spec.rb
dockly-3.1.1 spec/dockly/util/git_spec.rb
dockly-3.1.0 spec/dockly/util/git_spec.rb