Sha256: 2137b8a1e57648a9e686ad45a29e3e68e5dce90c79175731b1616fab4f40398a

Contents?: true

Size: 1.51 KB

Versions: 21

Compression:

Stored size: 1.51 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(:resolve).with('0.9.x')
      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(:resolve).with('0.9.x').and_return('93456ec7dc0f6fd3ac193b4df64f6544615dfbc9')
      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(:resolve).with('0.9.x').and_return('93456ec7dc0f6fd3ac193b4df64f6544615dfbc9')
      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

21 entries across 21 versions & 1 rubygems

Version Path
r10k-2.6.9 spec/unit/git/stateful_repository_spec.rb
r10k-2.6.8 spec/unit/git/stateful_repository_spec.rb
r10k-2.6.7 spec/unit/git/stateful_repository_spec.rb
r10k-2.6.6 spec/unit/git/stateful_repository_spec.rb
r10k-2.6.5 spec/unit/git/stateful_repository_spec.rb
r10k-2.6.4 spec/unit/git/stateful_repository_spec.rb
r10k-2.6.3 spec/unit/git/stateful_repository_spec.rb
r10k-2.6.2 spec/unit/git/stateful_repository_spec.rb
r10k-2.6.1 spec/unit/git/stateful_repository_spec.rb
r10k-2.6.0 spec/unit/git/stateful_repository_spec.rb
r10k-2.5.5 spec/unit/git/stateful_repository_spec.rb
r10k-2.5.4 spec/unit/git/stateful_repository_spec.rb
r10k-2.5.3 spec/unit/git/stateful_repository_spec.rb
r10k-2.5.2 spec/unit/git/stateful_repository_spec.rb
r10k-2.5.1 spec/unit/git/stateful_repository_spec.rb
r10k-2.4.5 spec/unit/git/stateful_repository_spec.rb
r10k-2.4.4 spec/unit/git/stateful_repository_spec.rb
r10k-2.5.0 spec/unit/git/stateful_repository_spec.rb
r10k-2.4.3 spec/unit/git/stateful_repository_spec.rb
r10k-2.4.1 spec/unit/git/stateful_repository_spec.rb