Sha256: 958026b629200faf6bbb4efb5e7b4bc19857cc14b3b22ac3adf779ebc70150e8

Contents?: true

Size: 1.55 KB

Versions: 3

Compression:

Stored size: 1.55 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')

describe ::Repomen::Repo::Handler::Git do
  before do
    tmp_dir = File.join(Repomen::ROOT, "tmp")
    Repomen.config.work_dir = tmp_dir
  end

  let(:described_class) { ::Repomen::Repo::Handler::Git }
  let(:dir) { "octocat/Hello-World" }

  describe "#retrieve" do
    it "should recognize a Github URL via git" do
      url = "git@github.com:octocat/Hello-World.git"
      handler = described_class.new(url, dir)
      handler.retrieve
      assert File.exists?(handler.path)
      assert File.directory?(handler.path)
    end

    it "should recognize a Github URL via https" do
      url = "https://github.com/octocat/Hello-World.git"
      handler = described_class.new(url, dir)
      handler.retrieve
      assert File.exists?(handler.path)
      assert File.directory?(handler.path)

      handler.discard
      assert !File.exists?(handler.path)
    end
  end

  describe "#git_options" do
    it "should include --depth=1 if only_last_revision is set" do
      url = "git@github.com:octocat/Hello-World.git"
      handler = described_class.new(url, dir, {:only_last_revision => true})
      options = handler.method(:git_options).call
      assert options.include?('--depth=1')
    end

    it "should NOT include --depth=1 if only_last_revision is set" do
      url = "git@github.com:octocat/Hello-World.git"
      handler = described_class.new(url, dir, {:only_last_revision => false})
      options = handler.method(:git_options).call
      assert !options.include?('--depth=1')
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
repomen-0.1.2 test/repomen/repo/handler/git_test.rb
repomen-0.1.1 test/repomen/repo/handler/git_test.rb
repomen-0.1.0 test/repomen/repo/handler/git_test.rb