Sha256: 82194909295ee8e43fa5695c58a9d9feac1ecbc985214f643e21535d0e90c9c1

Contents?: true

Size: 1.91 KB

Versions: 1

Compression:

Stored size: 1.91 KB

Contents

require 'spec_helper'

describe R10K::Deployment::Config do

  describe "reading settings" do
    # Try all permutations of string/symbol values as arguments to #setting and
    # values in the config file
    x = [:key, "key"]
    matrix = x.product(x)

    matrix.each do |(searchvalue, configvalue)|
      it "treats #{searchvalue.inspect}:#{searchvalue.class} and #{configvalue.inspect}:#{configvalue.class} as equivalent" do
        expect(YAML).to receive(:load_file).with('foo/bar').and_return(configvalue => 'some/cache')
        subject = described_class.new('foo/bar')
        expect(subject.setting(searchvalue)).to eq 'some/cache'
      end
    end
  end

  describe "applying global settings" do
    describe "for the cachedir" do
      it "sets the git cache root when given" do
        expect(YAML).to receive(:load_file).with('foo/bar').and_return('cachedir' => 'some/cache')
        expect(R10K::Git::Cache.settings).to receive(:[]=).with(:cache_root, 'some/cache')
        described_class.new('foo/bar')
      end
    end

    describe "for git" do
      it "sets the git provider when given" do
        expect(YAML).to receive(:load_file).with('foo/bar').and_return('git' => {'provider' => 'rugged'})
        expect(R10K::Git).to receive(:provider=).with(:rugged)
        described_class.new('foo/bar')
      end

      it "sets the git ssh username when given" do
        expect(YAML).to receive(:load_file).with('foo/bar').and_return('git' => {'username' => 'grit'})
        expect(R10K::Git.settings).to receive(:[]=).with(:username, 'grit')
        described_class.new('foo/bar')
      end

      it "sets the git private key when given" do
        expect(YAML).to receive(:load_file).with('foo/bar').and_return('git' => {'private_key' => '/home/user/.ssh/id_rsa'})
        expect(R10K::Git.settings).to receive(:[]=).with(:private_key, '/home/user/.ssh/id_rsa')
        described_class.new('foo/bar')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
r10k-1.5.1 spec/unit/deployment/config_spec.rb