puppet-check 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,7 @@ require_relative '../../lib/puppet-check/cli'
4
4
  describe PuppetCheck::CLI do
5
5
  context '.run' do
6
6
  it 'raises an error if no paths were specified' do
7
- expect { PuppetCheck::CLI.run(%w[-s -f]) }.to raise_error(RuntimeError, 'puppet-check: no paths specified; try using --help')
7
+ expect { PuppetCheck::CLI.run(%w[-s -f]) }.to raise_error(RuntimeError, 'puppet-check: no file paths specified; try using --help')
8
8
  end
9
9
  end
10
10
 
@@ -3,37 +3,38 @@ require_relative '../../lib/puppet-check/data_parser'
3
3
 
4
4
  describe DataParser do
5
5
  before(:each) do
6
- PuppetCheck.settings[:error_files] = []
7
- PuppetCheck.settings[:warning_files] = []
8
- PuppetCheck.settings[:clean_files] = []
6
+ PuppetCheck.files = {
7
+ errors: {},
8
+ warnings: {},
9
+ clean: [],
10
+ ignored: []
11
+ }
9
12
  end
10
13
 
11
14
  context '.yaml' do
12
- it 'puts a bad syntax yaml file in the error files array' do
15
+ it 'puts a bad syntax yaml file in the error files hash' do
13
16
  DataParser.yaml(["#{fixtures_dir}hieradata/syntax.yaml"])
14
- expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}hieradata/syntax.yaml:\nblock sequence entries are not allowed})
15
- expect(PuppetCheck.settings[:warning_files]).to eql([])
16
- expect(PuppetCheck.settings[:clean_files]).to eql([])
17
+ expect(PuppetCheck.files[:errors].keys).to eql(["#{fixtures_dir}hieradata/syntax.yaml"])
18
+ expect(PuppetCheck.files[:errors]["#{fixtures_dir}hieradata/syntax.yaml"].join("\n")).to match(%r{^block sequence entries are not allowed})
19
+ expect(PuppetCheck.files[:warnings]).to eql({})
20
+ expect(PuppetCheck.files[:clean]).to eql([])
17
21
  end
18
22
  it 'puts a good yaml file with potential hiera issues in the warning files array' do
19
23
  DataParser.yaml(["#{fixtures_dir}hieradata/style.yaml"])
20
- expect(PuppetCheck.settings[:error_files]).to eql([])
21
- expect(PuppetCheck.settings[:warning_files][0]).to match(%r{^#{fixtures_dir}hieradata/style.yaml:\nValue\(s\) missing in key.*\nValue\(s\) missing in key.*\nThe string --- appears more than once in this data and Hiera may fail to parse it correctly})
22
- expect(PuppetCheck.settings[:clean_files]).to eql([])
24
+ expect(PuppetCheck.files[:errors]).to eql({})
25
+ expect(PuppetCheck.files[:warnings].keys).to eql(["#{fixtures_dir}hieradata/style.yaml"])
26
+ expect(PuppetCheck.files[:warnings]["#{fixtures_dir}hieradata/style.yaml"].join("\n")).to match(%r{^Value\(s\) missing in key.*\nValue\(s\) missing in key.*\nThe string --- appears more than once in this data and Hiera may fail to parse it correctly})
27
+ expect(PuppetCheck.files[:clean]).to eql([])
23
28
  end
24
29
  it 'puts a good yaml file in the clean files array' do
25
30
  DataParser.yaml(["#{fixtures_dir}hieradata/good.yaml"])
26
- expect(PuppetCheck.settings[:error_files]).to eql([])
27
- expect(PuppetCheck.settings[:warning_files]).to eql([])
28
- expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}hieradata/good.yaml"])
31
+ expect(PuppetCheck.files[:errors]).to eql({})
32
+ expect(PuppetCheck.files[:warnings]).to eql({})
33
+ expect(PuppetCheck.files[:clean]).to eql(["#{fixtures_dir}hieradata/good.yaml"])
29
34
  end
30
35
  end
31
36
 
32
37
  context '.eyaml' do
33
- before(:each) do
34
- PuppetCheck.settings[:ignored_files] = []
35
- end
36
-
37
38
  it 'returns a warning if a public key was not specified' do
38
39
  expect { DataParser.eyaml(['foo.eyaml'], nil, 'private.pem') }.to output("Public X509 and/or Private RSA PKCS7 certs were not specified. EYAML checks will not be executed.\n").to_stderr
39
40
  end
@@ -43,74 +44,80 @@ describe DataParser do
43
44
  it 'returns a warning if the public key or private key are not existing files' do
44
45
  expect { DataParser.eyaml(['foo.eyaml'], 'public.pem', 'private.pem') }.to output("Specified Public X509 and/or Private RSA PKCS7 certs do not exist. EYAML checks will not be executed.\n").to_stderr
45
46
  end
46
- it 'puts a bad syntax eyaml file in the error files array' do
47
+ it 'puts a bad syntax eyaml file in the error files hash' do
47
48
  # DataParser.eyaml(["#{fixtures_dir}hieradata/syntax.eyaml'], fixtures_dir + 'keys/public_key.pkcs7.pem', fixtures_dir + 'keys/private_key.pkcs7.pem")
48
- # expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}hieradata/syntax.eyaml:\nblock sequence entries are not allowed})
49
- expect(PuppetCheck.settings[:warning_files]).to eql([])
50
- expect(PuppetCheck.settings[:clean_files]).to eql([])
49
+ # expect(PuppetCheck.files[:errors][0]).to match(%r{^#{fixtures_dir}hieradata/syntax.eyaml:\nblock sequence entries are not allowed})
50
+ expect(PuppetCheck.files[:warnings]).to eql({})
51
+ expect(PuppetCheck.files[:clean]).to eql([])
51
52
  end
52
53
  it 'puts a good eyaml file with potential hiera issues in the warning files array' do
53
54
  # DataParser.eyaml(["#{fixtures_dir}hieradata/style.eyaml'], fixtures_dir + 'keys/public_key.pkcs7.pem', fixtures_dir + 'keys/private_key.pkcs7.pem")
54
- expect(PuppetCheck.settings[:error_files]).to eql([])
55
- # expect(PuppetCheck.settings[:warning_files][0]).to match(%r{^#{fixtures_dir}hieradata/style.eyaml:\nValue\(s\) missing in key.*\nValue\(s\) missing in key.*\nThe string --- appears more than once in this data and Hiera will fail to parse it correctly})
56
- expect(PuppetCheck.settings[:clean_files]).to eql([])
55
+ expect(PuppetCheck.files[:errors]).to eql({})
56
+ # expect(PuppetCheck.files[:warnings].keys).to eql(["#{fixtures_dir}hieradata/style.eyaml"])
57
+ # expect(PuppetCheck.files[:warnings]["#{fixtures_dir}hieradata/style.eyaml"]).to match(%r{^Value\(s\) missing in key.*\nValue\(s\) missing in key.*\nThe string --- appears more than once in this data and Hiera will fail to parse it correctly})
58
+ expect(PuppetCheck.files[:clean]).to eql([])
57
59
  end
58
60
  it 'puts a good eyaml file in the clean files array' do
59
61
  # DataParser.eyaml(["#{fixtures_dir}hieradata/good.eyaml'], fixtures_dir + 'keys/public_key.pkcs7.pem', fixtures_dir + 'keys/private_key.pkcs7.pem")
60
- expect(PuppetCheck.settings[:error_files]).to eql([])
61
- expect(PuppetCheck.settings[:warning_files]).to eql([])
62
- # expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}hieradata/good.eyaml"])
62
+ expect(PuppetCheck.files[:errors]).to eql({})
63
+ expect(PuppetCheck.files[:warnings]).to eql({})
64
+ # expect(PuppetCheck.files[:clean]).to eql(["#{fixtures_dir}hieradata/good.eyaml"])
63
65
  end
64
66
  end
65
67
 
66
68
  context '.json' do
67
- it 'puts a bad syntax json file in the error files array' do
69
+ it 'puts a bad syntax json file in the error files hash' do
68
70
  DataParser.json(["#{fixtures_dir}hieradata/syntax.json"])
69
- expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}hieradata/syntax.json:\n.*unexpected token})
70
- expect(PuppetCheck.settings[:warning_files]).to eql([])
71
- expect(PuppetCheck.settings[:clean_files]).to eql([])
71
+ expect(PuppetCheck.files[:errors].keys).to eql(["#{fixtures_dir}hieradata/syntax.json"])
72
+ expect(PuppetCheck.files[:errors]["#{fixtures_dir}hieradata/syntax.json"].join("\n")).to match(%r{^.*unexpected token})
73
+ expect(PuppetCheck.files[:warnings]).to eql({})
74
+ expect(PuppetCheck.files[:clean]).to eql([])
72
75
  end
73
- it 'puts a bad metadata json file in the error files array' do
76
+ it 'puts a bad metadata json file in the error files hash' do
74
77
  DataParser.json(["#{fixtures_dir}metadata_syntax/metadata.json"])
75
- expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}metadata_syntax/metadata.json:\nRequired field.*\nField 'requirements'.*\nDuplicate dependencies.*\nDeprecated field.*\nSummary exceeds})
76
- expect(PuppetCheck.settings[:warning_files]).to eql([])
77
- expect(PuppetCheck.settings[:clean_files]).to eql([])
78
+ expect(PuppetCheck.files[:errors].keys).to eql(["#{fixtures_dir}metadata_syntax/metadata.json"])
79
+ expect(PuppetCheck.files[:errors]["#{fixtures_dir}metadata_syntax/metadata.json"].join("\n")).to match(%r{^Required field.*\nField 'requirements'.*\nDuplicate dependencies.*\nDeprecated field.*\nSummary exceeds})
80
+ expect(PuppetCheck.files[:warnings]).to eql({})
81
+ expect(PuppetCheck.files[:clean]).to eql([])
78
82
  end
79
83
  it 'puts a bad style metadata json file in the warning files array' do
80
84
  DataParser.json(["#{fixtures_dir}metadata_style/metadata.json"])
81
- expect(PuppetCheck.settings[:error_files]).to eql([])
82
- expect(PuppetCheck.settings[:warning_files][0]).to match(%r{^#{fixtures_dir}metadata_style/metadata.json:\n'pe' is missing an upper bound.\n.*operatingsystem_support.*\nLicense identifier})
83
- expect(PuppetCheck.settings[:clean_files]).to eql([])
85
+ expect(PuppetCheck.files[:errors]).to eql({})
86
+ expect(PuppetCheck.files[:warnings].keys).to eql(["#{fixtures_dir}metadata_style/metadata.json"])
87
+ expect(PuppetCheck.files[:warnings]["#{fixtures_dir}metadata_style/metadata.json"].join("\n")).to match(%r{^'pe' is missing an upper bound.\n.*operatingsystem_support.*\nLicense identifier})
88
+ expect(PuppetCheck.files[:clean]).to eql([])
84
89
  end
85
90
  it 'puts another bad style metadata json file in the warning files array' do
86
91
  DataParser.json(["#{fixtures_dir}metadata_style_two/metadata.json"])
87
- expect(PuppetCheck.settings[:error_files]).to eql([])
88
- expect(PuppetCheck.settings[:warning_files][0]).to match(%r{^#{fixtures_dir}metadata_style_two/metadata.json:\n'puppetlabs/one' has non-semantic versioning.*\n'puppetlabs/two' is missing an upper bound\.\n.*operatingsystem.*\n.*operatingsystemrelease})
89
- expect(PuppetCheck.settings[:clean_files]).to eql([])
92
+ expect(PuppetCheck.files[:errors]).to eql({})
93
+ expect(PuppetCheck.files[:warnings].keys).to eql(["#{fixtures_dir}metadata_style_two/metadata.json"])
94
+ expect(PuppetCheck.files[:warnings]["#{fixtures_dir}metadata_style_two/metadata.json"].join("\n")).to match(%r{^'puppetlabs/one' has non-semantic versioning.*\n'puppetlabs/two' is missing an upper bound\.\n.*operatingsystem.*\n.*operatingsystemrelease})
95
+ expect(PuppetCheck.files[:clean]).to eql([])
90
96
  end
91
97
  it 'puts a bad task metadata json file in the warning files array' do
92
98
  DataParser.json(["#{fixtures_dir}task_metadata/task_bad.json"])
93
- expect(PuppetCheck.settings[:error_files]).to eql([])
94
- expect(PuppetCheck.settings[:warning_files][0]).to match(%r{^#{fixtures_dir}task_metadata/task_bad.json:\ndescription value is not a String\ninput_method value is not one of environment, stdin, or powershell\nparameters value is not a Hash\npuppet_task_version value is not an Integer\nsupports_noop value is not a Boolean})
95
- expect(PuppetCheck.settings[:clean_files]).to eql([])
99
+ expect(PuppetCheck.files[:errors]).to eql({})
100
+ expect(PuppetCheck.files[:warnings].keys).to eql(["#{fixtures_dir}task_metadata/task_bad.json"])
101
+ expect(PuppetCheck.files[:warnings]["#{fixtures_dir}task_metadata/task_bad.json"].join("\n")).to match(%r{^description value is not a String\ninput_method value is not one of environment, stdin, or powershell\nparameters value is not a Hash\npuppet_task_version value is not an Integer\nsupports_noop value is not a Boolean})
102
+ expect(PuppetCheck.files[:clean]).to eql([])
96
103
  end
97
104
  it 'puts a good json file in the clean files array' do
98
105
  DataParser.json(["#{fixtures_dir}hieradata/good.json"])
99
- expect(PuppetCheck.settings[:error_files]).to eql([])
100
- expect(PuppetCheck.settings[:warning_files]).to eql([])
101
- expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}hieradata/good.json"])
106
+ expect(PuppetCheck.files[:errors]).to eql({})
107
+ expect(PuppetCheck.files[:warnings]).to eql({})
108
+ expect(PuppetCheck.files[:clean]).to eql(["#{fixtures_dir}hieradata/good.json"])
102
109
  end
103
110
  it 'puts a good metadata json file in the clean files array' do
104
111
  DataParser.json(["#{fixtures_dir}metadata_good/metadata.json"])
105
- expect(PuppetCheck.settings[:error_files]).to eql([])
106
- expect(PuppetCheck.settings[:warning_files]).to eql([])
107
- expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}metadata_good/metadata.json"])
112
+ expect(PuppetCheck.files[:errors]).to eql({})
113
+ expect(PuppetCheck.files[:warnings]).to eql({})
114
+ expect(PuppetCheck.files[:clean]).to eql(["#{fixtures_dir}metadata_good/metadata.json"])
108
115
  end
109
116
  it 'puts a good task metadata json file in the clean files array' do
110
117
  DataParser.json(["#{fixtures_dir}task_metadata/task_good.json"])
111
- expect(PuppetCheck.settings[:error_files]).to eql([])
112
- expect(PuppetCheck.settings[:warning_files]).to eql([])
113
- expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}task_metadata/task_good.json"])
118
+ expect(PuppetCheck.files[:errors]).to eql({})
119
+ expect(PuppetCheck.files[:warnings]).to eql({})
120
+ expect(PuppetCheck.files[:clean]).to eql(["#{fixtures_dir}task_metadata/task_good.json"])
114
121
  end
115
122
  end
116
123
  end
@@ -3,73 +3,62 @@ require_relative '../../lib/puppet-check/output_results'
3
3
 
4
4
  describe OutputResults do
5
5
  context '.text' do
6
- before(:each) do
7
- PuppetCheck.settings[:error_files] = []
8
- PuppetCheck.settings[:warning_files] = []
9
- PuppetCheck.settings[:clean_files] = []
10
- PuppetCheck.settings[:ignored_files] = []
11
- end
12
-
13
6
  it 'outputs files with errors' do
14
- PuppetCheck.settings[:error_files] = ['foo: i had an error']
15
- expect { OutputResults.text }.to output("\033[31mThe following files have errors:\033[0m\n-- foo: i had an error\n").to_stdout
7
+ files = { errors: { 'foo' => ['i had an error'] } }
8
+ expect { OutputResults.text(files) }.to output("\033[31mThe following files have errors:\033[0m\n-- foo:\ni had an error\n").to_stdout
16
9
  end
17
10
  it 'outputs files with warnings' do
18
- PuppetCheck.settings[:warning_files] = ['foo: i had a warning']
19
- expect { OutputResults.text }.to output("\n\033[33mThe following files have warnings:\033[0m\n-- foo: i had a warning\n").to_stdout
11
+ files = { warnings: { 'foo' => ['i had a warning'] } }
12
+ expect { OutputResults.text(files) }.to output("\n\033[33mThe following files have warnings:\033[0m\n-- foo:\ni had a warning\n").to_stdout
20
13
  end
21
14
  it 'outputs files with no errors or warnings' do
22
- PuppetCheck.settings[:clean_files] = ['foo: i was totally good to go']
23
- expect { OutputResults.text }.to output("\n\033[32mThe following files have no errors or warnings:\033[0m\n-- foo: i was totally good to go\n").to_stdout
15
+ files = { clean: ['foo'] }
16
+ expect { OutputResults.text(files) }.to output("\n\033[32mThe following files have no errors or warnings:\033[0m\n-- foo\n").to_stdout
24
17
  end
25
18
  it 'outputs files that were not processed' do
26
- PuppetCheck.settings[:ignored_files] = ['foo: who knows what i am']
27
- expect { OutputResults.text }.to output("\n\033[36mThe following files have unrecognized formats and therefore were not processed:\033[0m\n-- foo: who knows what i am\n").to_stdout
19
+ files = { ignored: ['foo'] }
20
+ expect { OutputResults.text(files) }.to output("\n\033[36mThe following files have unrecognized formats and therefore were not processed:\033[0m\n-- foo\n").to_stdout
28
21
  end
29
22
  end
30
23
 
31
- context '.markup' do
32
- before(:each) do
33
- PuppetCheck.settings[:error_files] = []
34
- PuppetCheck.settings[:warning_files] = []
35
- PuppetCheck.settings[:clean_files] = []
36
- PuppetCheck.settings[:ignored_files] = []
24
+ context '.run' do
25
+ it 'redirects to text output formatting as expected' do
26
+ expect { OutputResults.run({}, 'text') }.to output('').to_stdout
37
27
  end
38
-
39
28
  it 'outputs files with errors as yaml' do
40
- PuppetCheck.settings[:error_files] = ['foo: i had an error']
41
- expect { OutputResults.markup('yaml') }.to output("---\nerrors:\n- 'foo: i had an error'\n").to_stdout
29
+ files = { errors: { 'foo' => ['i had an error'] } }
30
+ expect { OutputResults.run(files, 'yaml') }.to output("---\nerrors:\n foo:\n - i had an error\n").to_stdout
42
31
  end
43
32
  it 'outputs files with warnings as yaml' do
44
- PuppetCheck.settings[:warning_files] = ['foo: i had a warning']
45
- expect { OutputResults.markup('yaml') }.to output("---\nwarnings:\n- 'foo: i had a warning'\n").to_stdout
33
+ files = { warnings: { 'foo' => ['i had a warning'] } }
34
+ expect { OutputResults.run(files, 'yaml') }.to output("---\nwarnings:\n foo:\n - i had a warning\n").to_stdout
46
35
  end
47
36
  it 'outputs files with no errors or warnings as yaml' do
48
- PuppetCheck.settings[:clean_files] = ['foo: i was totally good to go']
49
- expect { OutputResults.markup('yaml') }.to output("---\nclean:\n- 'foo: i was totally good to go'\n").to_stdout
37
+ files = { clean: ['foo'] }
38
+ expect { OutputResults.run(files, 'yaml') }.to output("---\nclean:\n- foo\n").to_stdout
50
39
  end
51
40
  it 'outputs files that were not processed as yaml' do
52
- PuppetCheck.settings[:ignored_files] = ['foo: who knows what i am']
53
- expect { OutputResults.markup('yaml') }.to output("---\nignored:\n- 'foo: who knows what i am'\n").to_stdout
41
+ files = { ignored: ['foo'] }
42
+ expect { OutputResults.run(files, 'yaml') }.to output("---\nignored:\n- foo\n").to_stdout
54
43
  end
55
44
  it 'outputs files with errors as json' do
56
- PuppetCheck.settings[:error_files] = ['foo: i had an error']
57
- expect { OutputResults.markup('json') }.to output("{\n \"errors\": [\n \"foo: i had an error\"\n ]\n}\n").to_stdout
45
+ files = { errors: { 'foo' => ['i had an error'] } }
46
+ expect { OutputResults.run(files, 'json') }.to output("{\n \"errors\": {\n \"foo\": [\n \"i had an error\"\n ]\n }\n}\n").to_stdout
58
47
  end
59
48
  it 'outputs files with warnings as json' do
60
- PuppetCheck.settings[:warning_files] = ['foo: i had a warning']
61
- expect { OutputResults.markup('json') }.to output("{\n \"warnings\": [\n \"foo: i had a warning\"\n ]\n}\n").to_stdout
49
+ files = { warnings: { 'foo' => ['i had a warning'] } }
50
+ expect { OutputResults.run(files, 'json') }.to output("{\n \"warnings\": {\n \"foo\": [\n \"i had a warning\"\n ]\n }\n}\n").to_stdout
62
51
  end
63
52
  it 'outputs files with no errors or warnings as json' do
64
- PuppetCheck.settings[:clean_files] = ['foo: i was totally good to go']
65
- expect { OutputResults.markup('json') }.to output("{\n \"clean\": [\n \"foo: i was totally good to go\"\n ]\n}\n").to_stdout
53
+ files = { clean: ['foo'] }
54
+ expect { OutputResults.run(files, 'json') }.to output("{\n \"clean\": [\n \"foo\"\n ]\n}\n").to_stdout
66
55
  end
67
56
  it 'outputs files that were not processed as json' do
68
- PuppetCheck.settings[:ignored_files] = ['foo: who knows what i am']
69
- expect { OutputResults.markup('json') }.to output("{\n \"ignored\": [\n \"foo: who knows what i am\"\n ]\n}\n").to_stdout
57
+ files = { ignored: ['foo'] }
58
+ expect { OutputResults.run(files, 'json') }.to output("{\n \"ignored\": [\n \"foo\"\n ]\n}\n").to_stdout
70
59
  end
71
60
  it 'raises an error for an unsupported output format' do
72
- expect { OutputResults.markup('awesomesauce') }.to raise_error(RuntimeError, 'puppet-check: Unsupported output format \'awesomesauce\' was specified.')
61
+ expect { OutputResults.run({}, 'awesomesauce') }.to raise_error(RuntimeError, 'puppet-check: Unsupported output format \'awesomesauce\' was specified.')
73
62
  end
74
63
  end
75
64
  end
@@ -3,72 +3,81 @@ require_relative '../../lib/puppet-check/puppet_parser'
3
3
 
4
4
  describe PuppetParser do
5
5
  before(:each) do
6
- PuppetCheck.settings[:error_files] = []
7
- PuppetCheck.settings[:warning_files] = []
8
- PuppetCheck.settings[:clean_files] = []
6
+ PuppetCheck.files = {
7
+ errors: {},
8
+ warnings: {},
9
+ clean: [],
10
+ ignored: []
11
+ }
9
12
  end
10
13
 
11
14
  context '.manifest' do
12
- it 'puts a bad syntax Puppet manifest in the error files array' do
15
+ it 'puts a bad syntax Puppet manifest in the error files hash' do
13
16
  PuppetParser.manifest(["#{fixtures_dir}manifests/syntax.pp"], false, [])
17
+ expect(PuppetCheck.files[:errors].keys).to eql(["#{fixtures_dir}manifests/syntax.pp"])
14
18
  if Gem::Version.new(Puppet::PUPPETVERSION) >= Gem::Version.new('6.5.0')
15
- expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}manifests/syntax.pp:\nLanguage validation logged 2 errors})
19
+ expect(PuppetCheck.files[:errors]["#{fixtures_dir}manifests/syntax.pp"].join("\n")).to match(%r{^Language validation logged 2 errors})
16
20
  else
17
- expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}manifests/syntax.pp:\nThis Variable has no effect.*\nIllegal variable name})
21
+ expect(PuppetCheck.files[:errors]["#{fixtures_dir}hieradata/syntax.yaml"].join("\n")).to match(%r{^This Variable has no effect.*\nIllegal variable name})
18
22
  end
19
- expect(PuppetCheck.settings[:warning_files]).to eql([])
20
- expect(PuppetCheck.settings[:clean_files]).to eql([])
23
+ expect(PuppetCheck.files[:warnings]).to eql({})
24
+ expect(PuppetCheck.files[:clean]).to eql([])
21
25
  end
22
26
  # puppet 5 api has output issues for this fixture
23
27
  unless Gem::Version.new(Puppet::PUPPETVERSION) < Gem::Version.new('6.0.0')
24
- it 'puts a bad syntax at eof Puppet manifest in the error files array' do
28
+ it 'puts a bad syntax at eof Puppet manifest in the error files hash' do
25
29
  PuppetParser.manifest(["#{fixtures_dir}manifests/eof_syntax.pp"], false, [])
26
- expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}manifests/eof_syntax.pp:\nSyntax error at end of input})
27
- expect(PuppetCheck.settings[:warning_files]).to eql([])
28
- expect(PuppetCheck.settings[:clean_files]).to eql([])
30
+ expect(PuppetCheck.files[:errors].keys).to eql(["#{fixtures_dir}manifests/eof_syntax.pp"])
31
+ expect(PuppetCheck.files[:errors]["#{fixtures_dir}manifests/eof_syntax.pp"].join("\n")).to match(%r{^Syntax error at end of input})
32
+ expect(PuppetCheck.files[:warnings]).to eql({})
33
+ expect(PuppetCheck.files[:clean]).to eql([])
29
34
  end
30
35
  end
31
- it 'puts a bad syntax Puppet plan in the error files array' do
36
+ it 'puts a bad syntax Puppet plan in the error files hash' do
32
37
  PuppetParser.manifest(["#{fixtures_dir}plans/syntax.pp"], false, [])
33
- expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}plans/syntax.pp:\nSyntax error at '\)'})
34
- expect(PuppetCheck.settings[:warning_files]).to eql([])
35
- expect(PuppetCheck.settings[:clean_files]).to eql([])
38
+ expect(PuppetCheck.files[:errors].keys).to eql(["#{fixtures_dir}plans/syntax.pp"])
39
+ expect(PuppetCheck.files[:errors]["#{fixtures_dir}plans/syntax.pp"].join("\n")).to match(%r{^Syntax error at '\)'})
40
+ expect(PuppetCheck.files[:warnings]).to eql({})
41
+ expect(PuppetCheck.files[:clean]).to eql([])
36
42
  end
37
- it 'puts a bad parser and lint style Puppet manifest in the warning files array' do
43
+ it 'puts a bad parser style and lint style Puppet manifest in the warning files array' do
38
44
  PuppetParser.manifest(["#{fixtures_dir}manifests/style_parser.pp"], true, [])
39
- expect(PuppetCheck.settings[:error_files]).to eql([])
40
- expect(PuppetCheck.settings[:warning_files][0]).to match(%r{^#{fixtures_dir}manifests/style_parser.pp:\nUnrecognized escape sequence.*\nUnrecognized escape sequence.*\n.*double quoted string containing})
41
- expect(PuppetCheck.settings[:clean_files]).to eql([])
45
+ expect(PuppetCheck.files[:errors]).to eql({})
46
+ expect(PuppetCheck.files[:warnings].keys).to eql(["#{fixtures_dir}manifests/style_parser.pp"])
47
+ expect(PuppetCheck.files[:warnings]["#{fixtures_dir}manifests/style_parser.pp"].join("\n")).to match(%r{^Unrecognized escape sequence.*\nUnrecognized escape sequence.*\n.*double quoted string containing})
48
+ expect(PuppetCheck.files[:clean]).to eql([])
42
49
  end
43
50
  it 'puts a bad lint style Puppet manifest in the warning files array' do
44
51
  PuppetParser.manifest(["#{fixtures_dir}manifests/style_lint.pp"], true, [])
45
- expect(PuppetCheck.settings[:error_files]).to eql([])
46
- expect(PuppetCheck.settings[:warning_files][0]).to match(%r{^#{fixtures_dir}manifests/style_lint.pp:\n.*(?:indentation of|double quoted string containing).*\n.*(?:indentation of|double quoted string containing)})
47
- expect(PuppetCheck.settings[:clean_files]).to eql([])
52
+ expect(PuppetCheck.files[:errors]).to eql({})
53
+ expect(PuppetCheck.files[:warnings].keys).to eql(["#{fixtures_dir}manifests/style_lint.pp"])
54
+ expect(PuppetCheck.files[:warnings]["#{fixtures_dir}manifests/style_lint.pp"].join("\n")).to match(%r{(?:indentation of|double quoted string containing).*\n.*(?:indentation of|double quoted string containing)})
55
+ expect(PuppetCheck.files[:clean]).to eql([])
48
56
  end
49
57
  it 'puts a bad style Puppet manifest in the clean files array when puppetlint_args ignores its warnings' do
50
58
  PuppetParser.manifest(["#{fixtures_dir}manifests/style_lint.pp"], true, ['--no-double_quoted_strings-check', '--no-arrow_alignment-check'])
51
- expect(PuppetCheck.settings[:error_files]).to eql([])
52
- expect(PuppetCheck.settings[:warning_files]).to eql([])
53
- expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}manifests/style_lint.pp"])
59
+ expect(PuppetCheck.files[:errors]).to eql({})
60
+ expect(PuppetCheck.files[:warnings]).to eql({})
61
+ expect(PuppetCheck.files[:clean]).to eql(["#{fixtures_dir}manifests/style_lint.pp"])
54
62
  end
55
63
  it 'puts a bad style Puppet plan in the warning files array' do
56
64
  PuppetParser.manifest(["#{fixtures_dir}plans/style.pp"], true, [])
57
- expect(PuppetCheck.settings[:error_files]).to eql([])
58
- expect(PuppetCheck.settings[:warning_files][0]).to match(%r{^#{fixtures_dir}plans/style.pp:\n.*variable not enclosed in {}})
59
- expect(PuppetCheck.settings[:clean_files]).to eql([])
65
+ expect(PuppetCheck.files[:errors]).to eql({})
66
+ expect(PuppetCheck.files[:warnings].keys).to eql(["#{fixtures_dir}plans/style.pp"])
67
+ expect(PuppetCheck.files[:warnings]["#{fixtures_dir}plans/style.pp"].join("\n")).to match(%r{variable not enclosed in {}})
68
+ expect(PuppetCheck.files[:clean]).to eql([])
60
69
  end
61
70
  it 'puts a good Puppet manifest in the clean files array' do
62
71
  PuppetParser.manifest(["#{fixtures_dir}manifests/good.pp"], true, [])
63
- expect(PuppetCheck.settings[:error_files]).to eql([])
64
- expect(PuppetCheck.settings[:warning_files]).to eql([])
65
- expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}manifests/good.pp"])
72
+ expect(PuppetCheck.files[:errors]).to eql({})
73
+ expect(PuppetCheck.files[:warnings]).to eql({})
74
+ expect(PuppetCheck.files[:clean]).to eql(["#{fixtures_dir}manifests/good.pp"])
66
75
  end
67
76
  it 'puts a good Puppet plan in the clean files array' do
68
77
  PuppetParser.manifest(["#{fixtures_dir}plans/good.pp"], true, [])
69
- expect(PuppetCheck.settings[:error_files]).to eql([])
70
- expect(PuppetCheck.settings[:warning_files]).to eql([])
71
- expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}plans/good.pp"])
78
+ expect(PuppetCheck.files[:errors]).to eql({})
79
+ expect(PuppetCheck.files[:warnings]).to eql({})
80
+ expect(PuppetCheck.files[:clean]).to eql(["#{fixtures_dir}plans/good.pp"])
72
81
  end
73
82
  it 'throws a well specified error for an invalid PuppetLint argument' do
74
83
  expect { PuppetParser.manifest(["#{fixtures_dir}manifests/style_lint.pp"], true, ['--non-existent', '--does-not-exist']) }.to raise_error(RuntimeError, 'puppet-lint: invalid option supplied among --non-existent --does-not-exist')
@@ -76,17 +85,18 @@ describe PuppetParser do
76
85
  end
77
86
 
78
87
  context '.template' do
79
- it 'puts a bad syntax Puppet template in the error files array' do
88
+ it 'puts a bad syntax Puppet template in the error files hash' do
80
89
  PuppetParser.template(["#{fixtures_dir}templates/syntax.epp"])
81
- expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}templates/syntax.epp:\nThis Name has no effect})
82
- expect(PuppetCheck.settings[:warning_files]).to eql([])
83
- expect(PuppetCheck.settings[:clean_files]).to eql([])
90
+ expect(PuppetCheck.files[:errors].keys).to eql(["#{fixtures_dir}templates/syntax.epp"])
91
+ expect(PuppetCheck.files[:errors]["#{fixtures_dir}templates/syntax.epp"].join("\n")).to match(%r{^This Name has no effect})
92
+ expect(PuppetCheck.files[:warnings]).to eql({})
93
+ expect(PuppetCheck.files[:clean]).to eql([])
84
94
  end
85
95
  it 'puts a good Puppet template in the clean files array' do
86
96
  PuppetParser.template(["#{fixtures_dir}templates/good.epp"])
87
- expect(PuppetCheck.settings[:error_files]).to eql([])
88
- expect(PuppetCheck.settings[:warning_files]).to eql([])
89
- expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}templates/good.epp"])
97
+ expect(PuppetCheck.files[:errors]).to eql({})
98
+ expect(PuppetCheck.files[:warnings]).to eql({})
99
+ expect(PuppetCheck.files[:clean]).to eql(["#{fixtures_dir}templates/good.epp"])
90
100
  end
91
101
  end
92
102
  end
@@ -15,10 +15,10 @@ describe RSpecPuppetSupport do
15
15
 
16
16
  it 'creates missing directories, missing site.pp, missing symlinks, and a missing spec_helper' do
17
17
  # travis ci
18
- if ENV['TRAVIS'] == 'true' || ENV['GITHUB_ACTIONS'] == 'true'
18
+ if ENV['TRAVIS'] == 'true'
19
19
  expect { rspec_puppet_setup }.to output("puppetlabs/gruntmaster has an unspecified, or specified but unsupported, download method.\n").to_stderr
20
- # circle ci
21
- elsif ENV['CIRCLECI'] == 'true'
20
+ # circle ci and gh actions
21
+ elsif ENV['CIRCLECI'] == 'true' || ENV['GITHUB_ACTIONS'] == 'true'
22
22
  expect { rspec_puppet_setup }.to output("git is not installed and cannot be used to retrieve dependency modules\nsubversion is not installed and cannot be used to retrieve dependency modules\npuppetlabs/gruntmaster has an unspecified, or specified but unsupported, download method.\n").to_stderr
23
23
  else
24
24
  expect { rspec_puppet_setup }.to output("subversion is not installed and cannot be used to retrieve dependency modules\npuppetlabs/gruntmaster has an unspecified, or specified but unsupported, download method.\n").to_stderr
@@ -32,7 +32,7 @@ describe RSpecPuppetSupport do
32
32
  expect(File.file?('spec/spec_helper.rb')).to be true
33
33
 
34
34
  # .dependency_setup
35
- expect(File.directory?('spec/fixtures/modules/puppetlabs-lvm')).to be true unless ENV['CIRCLECI'] == 'true'
35
+ expect(File.directory?('spec/fixtures/modules/puppetlabs-lvm')).to be true unless ENV['CIRCLECI'] == 'true' || ENV['GITHUB_ACTIONS'] == 'true'
36
36
  expect(File.directory?('spec/fixtures/modules/stdlib')).to be true
37
37
  end
38
38
  end