File: puppet_lint_spec.rb

package info (click to toggle)
puppet-lint 4.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 932 kB
  • sloc: ruby: 11,769; sh: 16; makefile: 11
file content (46 lines) | stat: -rw-r--r-- 1,528 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# frozen_string_literal: true

require 'spec_helper_acceptance'

describe 'When executing puppet-lint' do
  let(:manifest_root) { File.join(File.dirname(__FILE__), '..', 'fixtures', 'test', 'manifests') }

  context 'with no manifest provided' do
    it 'returns an exit code of 1 with no arguments' do
      result = puppet_lint
      expect(result[:exit_code]).to eq(1)
    end

    it 'returns an exit code of 0 when given a single flag' do
      result = puppet_lint(['--help'])
      expect(result[:exit_code]).to eq(0)
    end

    it 'returns the correct version number with the --version flag' do
      result = puppet_lint(['--version'])
      expect(result[:stdout]).to match(PuppetLint::VERSION)
    end
  end

  context 'with a manifest provided' do
    it 'returns one error when there is one problem' do
      result = puppet_lint([File.join(manifest_root, 'fail.pp')])
      expect(result[:stdout]).to have_errors(1)
    end

    it 'returns zero errors when there is an ignore comment present' do
      result = puppet_lint([File.join(manifest_root, 'ignore.pp')])
      expect(result[:stdout]).to have_errors(0)
    end

    it 'returns one warning when there is one problem' do
      result = puppet_lint([File.join(manifest_root, 'warning.pp')])
      expect(result[:stdout]).to have_warnings(1)
    end

    it 'contains two warnings when there are two problems' do
      result = puppet_lint([File.join(manifest_root, 'two_warnings.pp')])
      expect(result[:stdout]).to have_warnings(2)
    end
  end
end