Sha256: 74d5b6f89f4e2f74b8271aefebf7b55b852e9bdb73f3b4734b89d52e1d899aa1

Contents?: true

Size: 1.99 KB

Versions: 4

Compression:

Stored size: 1.99 KB

Contents

require 'spec_helper'

describe Hieracles::Config do
  describe '.load' do
    context 'with an existing file' do
      let(:options) do
        { config: 'spec/files/config.yml', basepath: 'spec/files' }
      end
      before { Hieracles::Config.load options }

      it 'initialize config values' do
        expect(Hieracles::Config.classpath).to eq 'farm_modules/%s.pp'
        expect(Hieracles::Config.modulepath).to eq 'modules'
        expect(Hieracles::Config.hierafile).to eq 'hiera.yaml'
        expect(Hieracles::Config.format).to eq 'Console'
      end
    end

    context 'with additional parameters' do
      let(:hierapath) { 'hiera.yaml' }
      let(:options) do
        { config: 'spec/files/config.yml', basepath: 'spec/files', hierafile: hierapath }
      end
      before { Hieracles::Config.load options }

      it 'initialize config values' do
        expect(Hieracles::Config.classpath).to eq 'farm_modules/%s.pp'
        expect(Hieracles::Config.modulepath).to eq 'modules'
        expect(Hieracles::Config.hierafile).to eq hierapath
        expect(Hieracles::Config.format).to eq 'Console'
      end
    end

    context 'without an existing config file' do
      let(:options) do
        { config: 'spec/files/config_no.yml' }
      end
      before do
        FileUtils.rm(options[:config]) if File.exist? options[:config]
        Hieracles::Config.load options
      end
      after { FileUtils.rm(options[:config]) if File.exist? options[:config] }

      it 'creates a default config file' do
        expect(File.exist? options[:config]).to be_truthy
      end

      it 'initialize config values' do
        expect(Hieracles::Config.classpath).to eq 'manifests/classes/%s.pp'
      end
    end
  end

  describe '.defaultconfig' do
    it { expect(Hieracles::Config.defaultconfig).to be_truthy }
  end

  describe '.extract_params' do
    let(:str)  { 'bla=blu;one=two' }
    let(:expected) { { bla: 'blu', one: 'two' } }
    it { expect(Hieracles::Config.extract_params(str)).to eq expected }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hieracles-0.0.4 spec/lib/config_spec.rb
hieracles-0.0.3 spec/lib/config_spec.rb
hieracles-0.0.2 spec/lib/config_spec.rb
hieracles-0.0.1 spec/lib/config_spec.rb