Sha256: 3f4123105279efed8b88fe94eb068c4eca2defb5bf655516f45be24e68fe7a0b

Contents?: true

Size: 1.78 KB

Versions: 4

Compression:

Stored size: 1.78 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)

      assert handler.revision_info
      info = handler.revision_info
      refute info["name"].nil?
      refute info["email"].nil?
      refute info["date"].nil?
      refute info["commit"].nil?
      refute info["message"].nil?
    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

4 entries across 4 versions & 1 rubygems

Version Path
repomen-0.1.6 test/repomen/repo/handler/git_test.rb
repomen-0.1.5 test/repomen/repo/handler/git_test.rb
repomen-0.1.4 test/repomen/repo/handler/git_test.rb
repomen-0.1.3 test/repomen/repo/handler/git_test.rb