|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +require 'spec_helper_acceptance' |
| 4 | + |
| 5 | +describe 'When executing puppet-lint' do |
| 6 | + let(:manifest_root) { File.join(File.dirname(__FILE__), '..', 'fixtures', 'test', 'manifests') } |
| 7 | + |
| 8 | + context 'with no manifest provided' do |
| 9 | + it 'returns an exit code of 1 with no arguments' do |
| 10 | + result = puppet_lint |
| 11 | + expect(result[:exit_code]).to eq(1) |
| 12 | + end |
| 13 | + |
| 14 | + it 'returns an exit code of 0 when given a single flag' do |
| 15 | + result = puppet_lint(['--help']) |
| 16 | + expect(result[:exit_code]).to eq(0) |
| 17 | + end |
| 18 | + |
| 19 | + it 'returns the correct version number with the --version flag' do |
| 20 | + result = puppet_lint(['--version']) |
| 21 | + expect(result[:stdout]).to match(PuppetLint::VERSION) |
| 22 | + end |
| 23 | + end |
| 24 | + |
| 25 | + context 'with a manifest provided' do |
| 26 | + it 'returns one error when there is one problem' do |
| 27 | + result = puppet_lint([File.join(manifest_root, 'fail.pp')]) |
| 28 | + expect(result[:stdout]).to have_errors(1) |
| 29 | + end |
| 30 | + |
| 31 | + it 'returns zero errors when there is an ignore comment present' do |
| 32 | + result = puppet_lint([File.join(manifest_root, 'ignore.pp')]) |
| 33 | + expect(result[:stdout]).to have_errors(0) |
| 34 | + end |
| 35 | + |
| 36 | + it 'returns one warning when there is one problem' do |
| 37 | + result = puppet_lint([File.join(manifest_root, 'warning.pp')]) |
| 38 | + expect(result[:stdout]).to have_warnings(1) |
| 39 | + end |
| 40 | + |
| 41 | + it 'contains two warnings when there are two problems' do |
| 42 | + result = puppet_lint([File.join(manifest_root, 'two_warnings.pp')]) |
| 43 | + expect(result[:stdout]).to have_warnings(2) |
| 44 | + end |
| 45 | + end |
| 46 | +end |
0 commit comments