Sha256: b7929eb83009d0d2a4f1d0e21d10130b08a71184192ffbad12a0232ff0a0fdb7

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

require_relative '../../helper'

describe GitDuplicator::Repository do
  let(:path) { 'somepath' }
  let(:name) { 'something' }
  let(:url) { 'someurl' }
  let(:to_url) { 'someurl' }
  let(:repo) { described_class.new(name, url) }

  describe '#repo=' do
    it 'assignes the attribute in case of Git::Base type' do
      val = Git::Base.new
      repo.repo = val
      expect(repo.repo).to eq(val)
    end

    it 'raise ArgumentError in case the attribute type is not Git::Base' do
      expect { repo.repo = 1 }.to raise_error(TypeError)
    end
  end

  describe '#bare_clone' do
    before(:each) { allow(repo).to receive(:repo=) }
    it 'clones a repo' do
      expect(Git).to receive(:clone).with(url, name, path: path, bare: true)
      repo.bare_clone(path)
    end

    it 'raises an exception in case of failure' do
      expect { repo.bare_clone('') }
      .to raise_error(GitDuplicator::RepositoryCloningError)
    end
  end

  describe '#mirror' do
    it 'mirrors a repo' do
      repo.repo = Git::Base.new
      expect(repo.repo).to receive(:push).with(to_url, '--mirror')
      repo.mirror(to_url)
    end

    it 'raises an exception in case of failure' do
      expect { repo.mirror('') }
      .to raise_error(GitDuplicator::RepositoryMirorringError)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
git_duplicator-0.0.1 spec/git_duplicator/repository/repository_spec.rb