Sha256: 462871e46f8eae9fe83054ffba7739fe0e114fb7285e393da98ecd515caa9fc7

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

require 'spec_helper'

describe 'ghostbuster_templates' do
  let(:path) { "./modules/foo/templates/bar" }
  let(:code) { "" }

  context 'with fix disabled' do

    context 'when template usage is found in manifests' do

      before :each do
        expect(Dir).to receive(:glob){["./modules/foo/manifests/bar.pp" ]}
      end

      context 'when using full module name syntax' do
        it 'should not detect any problem' do
          expect(File).to receive(:readlines).with("./modules/foo/manifests/bar.pp").and_return(["file{'foo':", "  content => template('foo/bar'),", "  }"])
          expect(problems).to have(0).problems
        end
      end

      context 'when using $module_name syntax' do
        it 'should not detect any problem' do
          expect(File).to receive(:readlines).with("./modules/foo/manifests/bar.pp").and_return(["file{'foo':", "  content => template('bar/foo'),", "  }"])
          expect(File).to receive(:readlines).with("./modules/foo/manifests/bar.pp").and_return(["file{'foo':", '  content => template("${module_name}/bar"),', "  }"])
          expect(problems).to have(0).problems
        end
      end
    end

    context 'when template usage is not found in manifests' do
      it 'should detect one problem' do
        expect(problems).to have(1).problems
      end

      it 'should create a warning' do
        expect(problems).to contain_warning("Template foo/bar seems unused")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
puppet-ghostbuster-0.5.0 spec/puppet-lint/plugins/ghostbuster_templates_spec.rb