Sha256: 2fdfa7915ceda8a0d5bd55289cbdb6eca9ef84560db1747da2e48b653224d3f2

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 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.workdir).to eq(File.expand_path('.') + '/')
    end
  end

  describe '#sha' do
    it 'returns a shortened sha for the head object' do
      expect(subject.sha).to eq(`git rev-parse --short HEAD`[0..6])
    end
  end

  describe '#ls_files' do
    it 'returns an Array of the files for the given OID' do
      expect(subject.ls_files(subject.sha).map { |hash| hash[:name] }.sort)
        .to eq(`git ls-files`.split("\n").sort)
    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|
        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
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dockly-3.0.3 spec/dockly/util/git_spec.rb
dockly-3.0.2 spec/dockly/util/git_spec.rb
dockly-3.0.1 spec/dockly/util/git_spec.rb
dockly-3.0.0 spec/dockly/util/git_spec.rb