Sha256: 70bc9d193b256bff0fe61dd7d4621403edfd72bb107372fe8b414b979543c69b

Contents?: true

Size: 1.32 KB

Versions: 27

Compression:

Stored size: 1.32 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 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

27 entries across 27 versions & 1 rubygems

Version Path
r10k-3.10.0 spec/unit/git/stateful_repository_spec.rb
r10k-3.9.3 spec/unit/git/stateful_repository_spec.rb
r10k-3.9.2 spec/unit/git/stateful_repository_spec.rb
r10k-3.9.1 spec/unit/git/stateful_repository_spec.rb
r10k-3.9.0 spec/unit/git/stateful_repository_spec.rb
r10k-3.8.0 spec/unit/git/stateful_repository_spec.rb
r10k-3.7.0 spec/unit/git/stateful_repository_spec.rb
r10k-3.6.0 spec/unit/git/stateful_repository_spec.rb
r10k-3.5.2 spec/unit/git/stateful_repository_spec.rb
r10k-3.5.1 spec/unit/git/stateful_repository_spec.rb
r10k-3.5.0 spec/unit/git/stateful_repository_spec.rb
r10k-3.4.1 spec/unit/git/stateful_repository_spec.rb
r10k-3.4.0 spec/unit/git/stateful_repository_spec.rb
r10k-3.3.3 spec/unit/git/stateful_repository_spec.rb
r10k-3.2.3 spec/unit/git/stateful_repository_spec.rb
r10k-3.3.2 spec/unit/git/stateful_repository_spec.rb
r10k-3.3.1 spec/unit/git/stateful_repository_spec.rb
r10k-3.2.1 spec/unit/git/stateful_repository_spec.rb
r10k-3.0.4 spec/unit/git/stateful_repository_spec.rb
r10k-3.3.0 spec/unit/git/stateful_repository_spec.rb