Sha256: 0ac6ef4a6209a238ddaff05cf73133c8b22fb1bc85049cf475675a01024318ff

Contents?: true

Size: 1.47 KB

Versions: 7

Compression:

Stored size: 1.47 KB

Contents

require 'spec_helper'
require 'r10k/git'
require 'r10k/git/stateful_repository'

describe R10K::Git::StatefulRepository do

  let(:remote) { 'git://some.site/some-repo.git' }
  let(:ref) { '0.9.x' }

  subject { described_class.new(remote, '/some/nonexistent/basedir', 'some-dirname') }

  describe "determining if the cache needs to be synced" do
    let(:cache) { double('cache') }

    before { expect(R10K::Git.cache).to receive(:generate).with(remote).and_return(cache) }

    it "is true if the cache is absent" do
      expect(cache).to receive(:exist?).and_return false
      expect(subject.sync_cache?(ref)).to eq true
    end

    it "is true if the ref is HEAD" do
      expect(cache).to receive(:exist?).and_return true
      expect(subject.sync_cache?('HEAD')).to eq true
    end

    it "is true if the ref is unresolvable" do
      expect(cache).to receive(:exist?).and_return true
      expect(cache).to receive(:ref_type).with('0.9.x').and_return(:unknown)
      expect(subject.sync_cache?(ref)).to eq true
    end

    it "is true if the ref is not a tag or commit" do
      expect(cache).to receive(:exist?).and_return true
      expect(cache).to receive(:ref_type).with('0.9.x').and_return(:branch)
      expect(subject.sync_cache?(ref)).to eq true
    end

    it "is false otherwise" do
      expect(cache).to receive(:exist?).and_return true
      expect(cache).to receive(:ref_type).with('0.9.x').and_return(:tag)
      expect(subject.sync_cache?(ref)).to eq false
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
r10k-3.14.2 spec/unit/git/stateful_repository_spec.rb
r10k-3.14.1 spec/unit/git/stateful_repository_spec.rb
r10k-3.14.0 spec/unit/git/stateful_repository_spec.rb
r10k-3.13.0 spec/unit/git/stateful_repository_spec.rb
r10k-3.12.1 spec/unit/git/stateful_repository_spec.rb
r10k-3.12.0 spec/unit/git/stateful_repository_spec.rb
r10k-3.11.0 spec/unit/git/stateful_repository_spec.rb