Sha256: 2690a5a50a0cfce0f7ce0883275c63be1fed0f2eec4ce768c7393e08878cec12

Contents?: true

Size: 1.77 KB

Versions: 1

Compression:

Stored size: 1.77 KB

Contents

require 'spec_helper'

class ClassMixedWithDSLHelpers
  include Beaker::DSL

  def logger
    RSpec::Mocks::Double.new('logger').as_null_object
  end
end

describe ClassMixedWithDSLHelpers do
  let(:host) { instance_double('Beaker::Host') }
  let(:puppet) do
    { 'codedir' => '/usr/code', 'hiera_config' => '/usr/face' }
  end

  before do
    allow(host).to receive(:puppet) { puppet }
  end

  describe '#write_hiera_config_on' do
    let(:hierarchy) { [{ 'name' => 'common', 'path' => 'common.yaml' }] }

    it 'on host' do
      expect(subject).to receive(:create_remote_file).with(host, '/usr/face', %r{datadir: "/usr/code/hieradata"})
      subject.write_hiera_config_on(host, hierarchy)
    end
  end

  describe '#write_hiera_config' do
    let(:hierarchy) { [{ 'name' => 'common', 'path' => 'common.yaml' }] }

    it 'delegates to #write_hiera_config_on with the default host' do
      expect(subject).to receive(:default).and_return(host)
      expect(subject).to receive(:write_hiera_config_on).with(host, hierarchy).once
      subject.write_hiera_config(hierarchy)
    end
  end

  describe '#copy_hiera_data_to' do
    let(:path) { 'spec/fixtures/hieradata' }

    it 'on host' do
      expect(subject).to receive(:scp_to).with(host, File.expand_path(path), '/usr/code/hieradata')
      subject.copy_hiera_data_to(host, path)
    end
  end

  describe '#copy_hiera_data' do
    let(:path) { 'spec/fixtures/hieradata' }

    it 'delegates to #copy_hiera_data_to with the default host' do
      expect(subject).to receive(:default).and_return(host)
      expect(subject).to receive(:copy_hiera_data_to).with(host, path).once
      subject.copy_hiera_data(path)
    end
  end

  describe '#hiera_datadir' do
    it { expect(subject.hiera_datadir(host)).to eq('/usr/code/hieradata') }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
beaker-hiera-1.0.0 spec/beaker-hiera/helpers_spec.rb