Sha256: 30be3f71f7c08c6068754bf5f34f4bd8915eb2f78e9e55468a34b76b2e3749fc

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'

describe 'file_ensure' do
  let (:msg) { 'ensure set to present on file resource' }

  context 'with fix disabled' do
    context 'correct file resource declarations' do
      let (:code) {
        <<-EOS
        file { '/etc/sudoers':
          ensure => file,
        }

        file { '/etc/fstab':
          ensure => 'file',
        }
        EOS
      }

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

    context 'wrong file resource declarations' do
      let (:code) {
        <<-EOS
        file { '/etc/sudoers':
          ensure => present,
        }

        file { '/etc/fstab':
          ensure => 'present',
        }
        EOS
      }

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

      it 'should create a warning' do
        expect(problems).to contain_warning(msg).on_line(2).in_column(21)
        expect(problems).to contain_warning(msg).on_line(6).in_column(21)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
puppet-lint-file_ensure-check-0.1.0 spec/puppet-lint/plugins/check_file_ensure/check_file_ensure_spec.rb