Sha256: 91f4a200021819b84aaffaee1dcce2f17da1513d43b711a6aefa956a3153c9a8

Contents?: true

Size: 1.55 KB

Versions: 23

Compression:

Stored size: 1.55 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe 'manifest_whitespace_inherits_name_single_space_before' do
  let(:single_space_msg) { 'there should be a single space between the inherits statement and the name' }

  context 'with two spaces' do
    let(:code) do
      <<~EOF
        # example
        #
        # Main class, includes all other classes.
        #

        class example inherits  other::example {
          class { 'example2':
            param1 => 'value1',
          }
        }
      EOF
    end

    context 'with fix disabled' do
      it 'should detect a single problem' do
        expect(problems).to have(1).problem
      end

      it 'should create a error' do
        expect(problems).to contain_error(single_space_msg).on_line(6).in_column(23)
      end
    end

    context 'with fix enabled' do
      before do
        PuppetLint.configuration.fix = true
      end

      after do
        PuppetLint.configuration.fix = false
      end

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

      it 'should fix the manifest' do
        expect(problems).to contain_fixed(single_space_msg)
      end

      it 'should fix the space' do
        expect(manifest).to eq(
          <<~EOF,
            # example
            #
            # Main class, includes all other classes.
            #

            class example inherits other::example {
              class { 'example2':
                param1 => 'value1',
              }
            }
          EOF
        )
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
puppet-lint-manifest_whitespace-check-0.2.8 spec/puppet-lint/plugins/manifest_whitespace_class_inherits_spec.rb
puppet-lint-manifest_whitespace-check-0.2.7 spec/puppet-lint/plugins/manifest_whitespace_class_inherits_spec.rb
puppet-lint-manifest_whitespace-check-0.2.6 spec/puppet-lint/plugins/manifest_whitespace_class_inherits_spec.rb
puppet-lint-manifest_whitespace-check-0.2.5 spec/puppet-lint/plugins/manifest_whitespace_class_inherits_spec.rb
puppet-lint-manifest_whitespace-check-0.2.4 spec/puppet-lint/plugins/manifest_whitespace_class_inherits_spec.rb
puppet-lint-manifest_whitespace-check-0.2.3 spec/puppet-lint/plugins/manifest_whitespace_class_inherits_spec.rb
puppet-lint-manifest_whitespace-check-0.2.2 spec/puppet-lint/plugins/manifest_whitespace_class_inherits_spec.rb
puppet-lint-manifest_whitespace-check-0.2.1 spec/puppet-lint/plugins/manifest_whitespace_class_inherits_spec.rb
puppet-lint-manifest_whitespace-check-0.2.0 spec/puppet-lint/plugins/manifest_whitespace_class_inherits_spec.rb
puppet-lint-manifest_whitespace-check-0.1.17 spec/puppet-lint/plugins/manifest_whitespace_class_inherits_spec.rb
puppet-lint-manifest_whitespace-check-0.1.16 spec/puppet-lint/plugins/manifest_whitespace_class_inherits_spec.rb
puppet-lint-manifest_whitespace-check-0.1.15 spec/puppet-lint/plugins/manifest_whitespace_class_inherits_spec.rb
puppet-lint-manifest_whitespace-check-0.1.14 spec/puppet-lint/plugins/manifest_whitespace_class_inherits_spec.rb
puppet-lint-manifest_whitespace-check-0.1.13 spec/puppet-lint/plugins/manifest_whitespace_class_inherits_spec.rb
puppet-lint-manifest_whitespace-check-0.1.12 spec/puppet-lint/plugins/manifest_whitespace_class_inherits_spec.rb
puppet-lint-manifest_whitespace-check-0.1.11 spec/puppet-lint/plugins/manifest_whitespace_class_inherits_spec.rb
puppet-lint-manifest_whitespace-check-0.1.10 spec/puppet-lint/plugins/manifest_whitespace_class_inherits_spec.rb
puppet-lint-manifest_whitespace-check-0.1.9 spec/puppet-lint/plugins/manifest_whitespace_class_inherits_spec.rb
puppet-lint-manifest_whitespace-check-0.1.8 spec/puppet-lint/plugins/manifest_whitespace_class_inherits_spec.rb
puppet-lint-manifest_whitespace-check-0.1.7 spec/puppet-lint/plugins/manifest_whitespace_class_inherits_spec.rb