Sha256: c08e059d84b87db4c0ff917367041d0be06e049fb159496b672429587c6675a3

Contents?: true

Size: 1.88 KB

Versions: 3

Compression:

Stored size: 1.88 KB

Contents

require 'spec_helper'

describe 'strict_indent' do
  before do
    # disable all other checks
    PuppetLint.configuration.checks.reject{ |check|
      check == :indent
    }.each do |check|
      PuppetLint.configuration.send("disable_#{check}")
    end
  end

  after do
    # re-enable other checks
    PuppetLint.configuration.checks.reject{ |check|
      check == :indent
    }.each do |check|
      PuppetLint.configuration.send("enable_#{check}")
    end
  end

  context 'on manifest' do
    Dir['spec/fixtures/pass/*'].each do |manifest|
      context manifest do
        let(:code) { File.read(manifest) }

        it 'should detect no problems' do
          expect(problems).to have(0).problems
        end
      end
    end

    Dir['spec/fixtures/fail/*'].each do |manifest|
      context manifest do
        let(:code) { File.read(manifest) }

        it 'should detect problems' do
          expect(problems).to have(1).problems
        end
      end
    end
  end

  context 'comment after resource title.' do
    let(:code) {
      <<-EOF.gsub(/^ {8}/, '')
        class (
        ) {
          file {
            'this': #comment
              ensure  => 'present',
          }
        }
      EOF
    }

    it 'should detect 0 problems' do
      expect(problems).to have(0).problems
    end
  end

  context 'invalid array indent' do
    let(:code) {
      <<-EOF.gsub(/^ {8}/, '')
        class (
        ) {
          file { 'this':
            ensure  => 'present',
            require => [ 'abc',
                         'def', ],
          }
        }
      EOF
    }

    it 'should detect 1 problems' do
      expect(problems).to have(1).problems
    end
  end

  context 'blank line at beginning of file' do
    let(:code) {
      <<-EOF.gsub(/^ {8}/, '')

        class () {}
      EOF
    }

    it 'should detect 0 problems' do
      expect(problems).to have(0).problems
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
puppet-lint-strict_indent-check-2.1.0 spec/puppet-lint/plugins/check_strict_indent_spec.rb
puppet-lint-strict_indent-check-2.0.8 spec/puppet-lint/plugins/check_strict_indent_spec.rb
puppet-lint-strict_indent-check-2.0.7 spec/puppet-lint/plugins/check_strict_indent_spec.rb