Sha256: 4cec53514c46824d41145f6b3403db2d0e4a7838daa3c5e0106fdc899d270420

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'

describe R10K::Git::Rugged::Cache, :unless => R10K::Util::Platform.jruby? do
  before(:all) do
    require 'r10k/git/rugged/cache'
  end

  subject(:cache) { described_class.new('git://some/git/remote') }

  it "wraps a Rugged::BareRepository instance" do
    expect(cache.repo).to be_a_kind_of R10K::Git::Rugged::BareRepository
  end

  describe "settings" do
    before do
      R10K::Git::Cache.settings[:cache_root] = '/some/path'
      described_class.settings.reset!
    end

    after do
      R10K::Git::Cache.settings.reset!
      described_class.settings.reset!
    end

    it "falls back to the parent class settings" do
      expect(described_class.settings[:cache_root]).to eq '/some/path'
    end
  end

  describe "remote url updates" do
    before do
      allow(subject.repo).to receive(:exist?).and_return true
      allow(subject.repo).to receive(:fetch)
      allow(subject.repo).to receive(:remotes).and_return({ 'origin' => 'git://some/git/remote' })
    end

    it "does not update the URLs if they match" do
      expect(subject.repo).to_not receive(:update_remote)
      subject.sync!
    end

    it "updates the remote URL if they do not match" do
      allow(subject.repo).to receive(:remotes).and_return({ 'origin' => 'foo'})
      expect(subject.repo).to receive(:update_remote)
      subject.sync!
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
r10k-3.14.2 spec/unit/git/rugged/cache_spec.rb
r10k-3.14.1 spec/unit/git/rugged/cache_spec.rb
r10k-3.14.0 spec/unit/git/rugged/cache_spec.rb