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