Sha256: ee51d0ef9796835ca3b0e264a7a0b2ef6dca8fe4a002972a0b3e577479cf7c90

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe 'manifest_whitespace_missing_newline_end_of_file' do
  let(:single_newline_end_of_file_msg) { 'there should be a single newline at the end of a manifest' }

  context 'with fix disabled' do
    context 'with no new line at the end of a manifest' do
      let(:code) do
        'class example { }'
      end

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

      it 'creates a error' do
        expect(problems).to contain_error(single_newline_end_of_file_msg).on_line(1).in_column(17)
      end
    end
  end

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

    after do
      PuppetLint.configuration.fix = false
    end

    context 'with no new line at the end of a manifest' do
      let(:code) do
        'class example { }'
      end

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

      it 'fixes the manifest' do
        expect(problems).to contain_fixed(single_newline_end_of_file_msg).on_line(1).in_column(17)
      end

      it 'adds the final newline' do
        expect(manifest).to eq("class example { }\n")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
puppet-lint-manifest_whitespace-check-0.2.9 spec/puppet-lint/plugins/manifest_whitespace_missing_newline_end_of_file_spec.rb