Sha256: 03b74612584fd0297e2ac711299852c90d05722958b013737255424c1a979318

Contents?: true

Size: 1.44 KB

Versions: 16

Compression:

Stored size: 1.44 KB

Contents

require 'dply/repo'
require 'repo'

module Dply
  describe Repo do

    before :all do
      @work_dir = "tmp/repo"
      @source_repo = "#{Dir.pwd}/tmp/repo.git"
      FileUtils.rm_rf @work_dir
      FileUtils.mkdir_p @work_dir
    end

    def source_repo
      @source_repo
    end

    def tmp_dir(&block)
      d = Dir.mktmpdir nil, "#{Dir.pwd}/#{@work_dir}"
      Dir.chdir(d) { yield d }
    end

    subject(:repo) { Repo.new "repo", source_repo, mirror: nil }

    describe ".create" do
      it "creates the repo from the given upstream" do
        tmp_dir do |d|
          suppress_output { repo.create }
          expect(File).to exist("repo/.git")
        end
      end

      it "throws an error if a different git repo already exists at [dir]" do
        tmp_dir do |d|
          FileUtils.mkdir "repo"
          Dir.chdir "repo" do
            system! "touch a"
            system! "git init"
            system! "git add a; git commit -m 'commit'"
            system! "git remote add origin /some/other/upstream"
          end
          expect { repo.create }.to raise_error(Error)
        end
      end

      it "clones repo from a mirror if specified" do
        upstream = "/some/upstream.git"
        repo = Repo.new "repo", upstream, mirror: source_repo
        tmp_dir do
          suppress_output { repo.create }
          Dir.chdir "repo" do
            expect(Git.remote_url).to eq(upstream)
          end
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
dply-0.3.15 spec/dply/repo_spec.rb
dply-0.3.14 spec/dply/repo_spec.rb
dply-0.3.13 spec/dply/repo_spec.rb
dply-0.3.12 spec/dply/repo_spec.rb
dply-0.3.11 spec/dply/repo_spec.rb
dply-0.3.10 spec/dply/repo_spec.rb
dply-0.3.9 spec/dply/repo_spec.rb
dply-0.3.8 spec/dply/repo_spec.rb
dply-0.3.7 spec/dply/repo_spec.rb
dply-0.3.6 spec/dply/repo_spec.rb
dply-0.3.5 spec/dply/repo_spec.rb
dply-0.3.4 spec/dply/repo_spec.rb
dply-0.3.3 spec/dply/repo_spec.rb
dply-0.3.2 spec/dply/repo_spec.rb
dply-0.3.1 spec/dply/repo_spec.rb
dply-0.3.0 spec/dply/repo_spec.rb