File: cache_spec.rb

package info (click to toggle)
r10k 5.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,228 kB
  • sloc: ruby: 18,180; makefile: 10; sh: 1
file content (48 lines) | stat: -rw-r--r-- 1,376 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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('https://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' => 'https://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