puppet-check 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,7 +21,7 @@ class PuppetParser
21
21
  Puppet::Face[:parser, :current].validate(file)
22
22
  # this is the actual error that we need to rescue Puppet::Face from
23
23
  rescue SystemExit
24
- next PuppetCheck.error_files.push("#{file}:\n#{errors.map(&:to_s).join("\n").gsub("#{File.absolute_path(file)}:", '')}")
24
+ next PuppetCheck.settings[:error_files].push("#{file}:\n#{errors.map(&:to_s).join("\n").gsub("#{File.absolute_path(file)}:", '')}")
25
25
  end
26
26
 
27
27
  # initialize warnings with output from the parser if it exists, since the output is warnings if Puppet::Face did not trigger a SystemExit
@@ -50,8 +50,8 @@ class PuppetParser
50
50
  puppet_lint.problems.each { |values| warnings += "\n#{values[:line]}:#{values[:column]}: #{values[:message]}" }
51
51
  end
52
52
  end
53
- next PuppetCheck.warning_files.push(warnings) unless warnings == "#{file}:"
54
- PuppetCheck.clean_files.push(file.to_s)
53
+ next PuppetCheck.settings[:warning_files].push(warnings) unless warnings == "#{file}:"
54
+ PuppetCheck.settings[:clean_files].push(file.to_s)
55
55
  end
56
56
  end
57
57
 
@@ -61,16 +61,16 @@ class PuppetParser
61
61
 
62
62
  files.each do |file|
63
63
  # puppet before version 4 cannot check template syntax
64
- next PuppetCheck.ignored_files.push("#{file}: ignored due to Puppet < 4") if Puppet::PUPPETVERSION.to_i < 4
64
+ next PuppetCheck.settings[:ignored_files].push("#{file}: ignored due to Puppet < 4") if Puppet::PUPPETVERSION.to_i < 4
65
65
 
66
66
  # check puppet template syntax
67
67
  begin
68
68
  # credits to gds-operations/puppet-syntax for the parser function call
69
69
  Puppet::Pops::Parser::EvaluatingParser::EvaluatingEppParser.new.parse_file(file)
70
70
  rescue StandardError => err
71
- PuppetCheck.error_files.push("#{file}:\n#{err.to_s.gsub("#{file}:", '')}")
71
+ PuppetCheck.settings[:error_files].push("#{file}:\n#{err.to_s.gsub("#{file}:", '')}")
72
72
  else
73
- PuppetCheck.clean_files.push(file.to_s)
73
+ PuppetCheck.settings[:clean_files].push(file.to_s)
74
74
  end
75
75
  end
76
76
  end
@@ -14,8 +14,8 @@ class RegressionCheck
14
14
 
15
15
  # regression testing
16
16
  # def self.regression(nodes, octoconfig)
17
- # options = RegressionCheck.config(octoconfig)
18
- # nodes.each { |node| stuff }
17
+ # options = RegressionCheck.config(octoconfig)
18
+ # nodes.each { |node| stuff }
19
19
  # end
20
20
 
21
21
  # config file loading
@@ -4,7 +4,7 @@ class RSpecPuppetSupport
4
4
  # 'puppetcheck:spec' task invokes 'run'
5
5
  # 'run' invokes 'file_setup' always and 'dependency_setup' if metadata.json exists
6
6
  # 'dependency_setup' invokes 'git/forge/hg' if dependencies exist and git/forge/hg is download option
7
- # 'git/forge/hg' downloads module fixture appropriately
7
+ # 'git/forge/svn/hg' downloads module fixture appropriately
8
8
 
9
9
  # prepare the spec fixtures directory for rspec-puppet testing
10
10
  def self.run
@@ -39,7 +39,7 @@ class RSpecPuppetSupport
39
39
  File.write('spec/fixtures/manifests/site.pp', '') unless File.file?('spec/fixtures/manifests/site.pp')
40
40
 
41
41
  # symlink over everything the module needs for compilation
42
- %w(hiera.yaml data hieradata functions manifests lib files templates).each do |file|
42
+ %w[hiera.yaml data hieradata functions manifests lib files templates].each do |file|
43
43
  File.symlink("../../../../#{file}", "spec/fixtures/modules/#{module_name}/#{file}") if File.exist?(file) && !File.exist?("spec/fixtures/modules/#{module_name}/#{file}")
44
44
  end
45
45
 
@@ -63,6 +63,8 @@ class RSpecPuppetSupport
63
63
  git(dependency_hash['git'], dependency_hash['args'])
64
64
  elsif dependency_hash.key?('forge')
65
65
  forge(dependency_hash['forge'], dependency_hash['args'])
66
+ elsif dependency_hash.key?('svn')
67
+ svn(dependency_hash['svn'], dependency_hash['args'])
66
68
  elsif dependency_hash.key?('hg')
67
69
  hg(dependency_hash['hg'], dependency_hash['args'])
68
70
  else
@@ -81,11 +83,17 @@ class RSpecPuppetSupport
81
83
 
82
84
  # download external module dependency with forge
83
85
  def self.forge(forge_name, args = '')
84
- if File.directory?("spec/fixtures/modules/#{forge_name}")
85
- system("puppet module upgrade --modulepath spec/fixtures/modules/ #{args} #{forge_name}")
86
- else
87
- system("puppet module install --modulepath spec/fixtures/modules/ #{args} #{forge_name}")
88
- end
86
+ # is the module present? do an upgrade; otherwise, do an install
87
+ subcommand = File.directory?("spec/fixtures/modules/#{forge_name}") ? 'upgrade' : 'install'
88
+ system("puppet module #{subcommand} --modulepath spec/fixtures/modules/ #{args} #{forge_name}")
89
+ end
90
+
91
+ # download external module dependency with svn
92
+ def self.svn(svn_url, args = '')
93
+ # establish path to checkout module to
94
+ path = "spec/fixtures/modules/#{File.basename(svn_url)}"
95
+ # is the module present and already checked out with svn? do an update; otherwise, do a checkout
96
+ File.directory?("#{path}/.svn") ? system("svn update #{path}") : system("svn co #{args} #{svn_url} #{path}")
89
97
  end
90
98
 
91
99
  # download external module dependency with hg
@@ -11,7 +11,7 @@ class RubyParser
11
11
  # prevents ruby code from actually executing
12
12
  catch(:good) { instance_eval("BEGIN {throw :good}; #{File.read(file)}") }
13
13
  rescue ScriptError, StandardError => err
14
- PuppetCheck.error_files.push("#{file}:\n#{err}")
14
+ PuppetCheck.settings[:error_files].push("#{file}:\n#{err}")
15
15
  else
16
16
  # check ruby style
17
17
  if style
@@ -28,9 +28,9 @@ class RubyParser
28
28
  warnings += reek_warnings.split("\n")[1..-1].map(&:strip).join("\n") unless reek_warnings == ''
29
29
 
30
30
  # return warnings
31
- next PuppetCheck.warning_files.push("#{file}:\n#{warnings.strip}") unless warnings == ''
31
+ next PuppetCheck.settings[:warning_files].push("#{file}:\n#{warnings.strip}") unless warnings == ''
32
32
  end
33
- PuppetCheck.clean_files.push(file.to_s)
33
+ PuppetCheck.settings[:clean_files].push(file.to_s)
34
34
  end
35
35
  end
36
36
  end
@@ -49,11 +49,11 @@ class RubyParser
49
49
  # empty out warnings since it would contain an error if this pass triggers
50
50
  warnings = ''
51
51
  rescue ScriptError => err
52
- next PuppetCheck.error_files.push("#{file}:\n#{err}")
52
+ next PuppetCheck.settings[:error_files].push("#{file}:\n#{err}")
53
53
  end
54
54
  # return warnings from the check if there were any
55
- next PuppetCheck.warning_files.push("#{file}:\n#{warnings.gsub('warning: ', '').split('(erb):').join('').strip}") unless warnings == ''
56
- PuppetCheck.clean_files.push(file.to_s)
55
+ next PuppetCheck.settings[:warning_files].push("#{file}:\n#{warnings.gsub('warning: ', '').split('(erb):').join('').strip}") unless warnings == ''
56
+ PuppetCheck.settings[:clean_files].push(file.to_s)
57
57
  end
58
58
  end
59
59
 
@@ -65,7 +65,7 @@ class RubyParser
65
65
  # prevents ruby code from actually executing
66
66
  catch(:good) { instance_eval("BEGIN {throw :good}; #{File.read(file)}") }
67
67
  rescue SyntaxError, LoadError, ArgumentError => err
68
- PuppetCheck.error_files.push("#{file}:\n#{err}")
68
+ PuppetCheck.settings[:error_files].push("#{file}:\n#{err}")
69
69
  # check librarian puppet style
70
70
  else
71
71
  if style
@@ -77,9 +77,9 @@ class RubyParser
77
77
  warnings = Utils.capture_stdout { RuboCop::CLI.new.run(rc_args + ['--format', 'emacs', file]) }
78
78
 
79
79
  # collect style warnings
80
- next PuppetCheck.warning_files.push("#{file}:\n#{warnings.split("#{File.absolute_path(file)}:").join('')}") unless warnings.empty?
80
+ next PuppetCheck.settings[:warning_files].push("#{file}:\n#{warnings.split("#{File.absolute_path(file)}:").join('')}") unless warnings.empty?
81
81
  end
82
- PuppetCheck.clean_files.push(file.to_s)
82
+ PuppetCheck.settings[:clean_files].push(file.to_s)
83
83
  end
84
84
  end
85
85
  end
@@ -1,13 +1,15 @@
1
- require 'rspec/core/rake_task'
2
- require 'rake/tasklib'
1
+ begin
2
+ require 'rake/tasklib'
3
+ rescue LoadError
4
+ raise 'Rake is not installed and you are attempting to execute Rake tasks with Puppet Check. Please install Rake before continuing.'
5
+ end
3
6
  require_relative '../puppet-check'
4
- require_relative 'rspec_puppet_support'
5
7
 
6
8
  # the rake interface for PuppetCheck
7
9
  class PuppetCheck::Tasks < ::Rake::TaskLib
8
10
  def initialize
9
11
  desc 'Execute all Puppet-Check checks'
10
- task puppetcheck: %w(puppetcheck:file puppetcheck:spec puppetcheck:beaker)
12
+ task puppetcheck: %w[puppetcheck:file puppetcheck:spec puppetcheck:beaker]
11
13
 
12
14
  namespace :puppetcheck do
13
15
  desc 'Execute Puppet-Check file checks'
@@ -15,21 +17,28 @@ class PuppetCheck::Tasks < ::Rake::TaskLib
15
17
  PuppetCheck.new.run(Dir.glob('*'))
16
18
  end
17
19
 
18
- desc 'Execute RSpec and RSpec-Puppet tests'
19
- RSpec::Core::RakeTask.new(:spec) do |task|
20
- RSpecPuppetSupport.run
21
- # generate tasks for all recognized directories and ensure spec tests inside module dependencies are ignored
22
- spec_dirs = Dir.glob('**/{classes,defines,facter,functions,hosts,puppet,unit,types}/**/*_spec.rb').reject { |dir| dir =~ /fixtures/ }
23
- task.pattern = spec_dirs.empty? ? 'skip_rspec' : spec_dirs
24
- task.rspec_opts = '-f json' if PuppetCheck.output_format == 'json'
25
- end
20
+ begin
21
+ require 'rspec/core/rake_task'
22
+ require_relative 'rspec_puppet_support'
23
+
24
+ desc 'Execute RSpec and RSpec-Puppet tests'
25
+ RSpec::Core::RakeTask.new(:spec) do |task|
26
+ RSpecPuppetSupport.run
27
+ # generate tasks for all recognized directories and ensure spec tests inside module dependencies are ignored
28
+ spec_dirs = Dir.glob('**/{classes,defines,facter,functions,hosts,puppet,unit,types}/**/*_spec.rb').reject { |dir| dir =~ /fixtures/ }
29
+ task.pattern = spec_dirs.empty? ? 'skip_rspec' : spec_dirs
30
+ task.rspec_opts = '-f json' if PuppetCheck.settings[:output_format] == 'json'
31
+ end
26
32
 
27
- desc 'Execute Beaker acceptance tests'
28
- RSpec::Core::RakeTask.new(:beaker) do |task|
29
- # generate tasks for all recognized directories and ensure acceptance tests inside module dependencies are ignored
30
- acceptance_dirs = Dir.glob('**/acceptance').reject { |dir| dir =~ /fixtures/ }
31
- task.pattern = acceptance_dirs.empty? ? 'skip_beaker' : acceptance_dirs
32
- task.rspec_opts = '-f json' if PuppetCheck.output_format == 'json'
33
+ desc 'Execute Beaker acceptance tests'
34
+ RSpec::Core::RakeTask.new(:beaker) do |task|
35
+ # generate tasks for all recognized directories and ensure acceptance tests inside module dependencies are ignored
36
+ acceptance_dirs = Dir.glob('**/acceptance').reject { |dir| dir =~ /fixtures/ }
37
+ task.pattern = acceptance_dirs.empty? ? 'skip_beaker' : acceptance_dirs
38
+ task.rspec_opts = '-f json' if PuppetCheck.settings[:output_format] == 'json'
39
+ end
40
+ rescue LoadError
41
+ puts 'RSpec is not installed. The RSpec/RSpecPuppet and Beaker tasks will not be available.'
33
42
  end
34
43
  end
35
44
  end
@@ -40,6 +40,11 @@
40
40
  "version_requirement": ">= 0.5.0 < 1.0.0",
41
41
  "git": "https://github.com/puppetlabs/puppetlabs-lvm.git"
42
42
  },
43
+ {
44
+ "name": "puppetlabs/foo",
45
+ "version_requirement": ">= 0.0.0 < 1.0.0",
46
+ "svn": "https://www.doesnotexist.com/foo"
47
+ },
43
48
  {
44
49
  "name": "puppetlabs/gruntmaster",
45
50
  "version_requirement": ">= 6000.0.0 < 9000.0.0",
@@ -1,6 +1,5 @@
1
1
  ---
2
- :backends:
3
- - yaml
2
+ :backends: yaml
4
3
  :yaml:
5
4
  :datadir: "hieradata"
6
5
  :hierarchy:
@@ -9,7 +9,11 @@ module OctocatalogDiff
9
9
  settings[:hiera_config] = octocatalog_diff_dir + 'hiera.yaml'
10
10
  settings[:hiera_path] = octocatalog_diff_dir + 'hieradata'
11
11
  settings[:fact_file] = octocatalog_diff_dir + 'facts.yaml'
12
- settings[:puppet_binary] = '/usr/local/bin/puppet'
12
+ settings[:puppet_binary] = if File.directory?('/home/travis')
13
+ octocatalog_diff_dir + '../../bin/puppet'
14
+ else
15
+ '/usr/local/bin/puppet'
16
+ end
13
17
  settings[:bootstrapped_to_dir] = octocatalog_diff_dir
14
18
 
15
19
  settings
@@ -4,69 +4,71 @@ 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 paths specified; try using --help')
8
8
  end
9
9
  end
10
10
 
11
11
  context '.parse' do
12
12
  it 'raises an error if an invalid option was specified' do
13
- expect { PuppetCheck::CLI.parse(%w(-s -f -asdf foo)) }.to raise_error(OptionParser::InvalidOption)
13
+ expect { PuppetCheck::CLI.parse(%w[-s -f -asdf foo]) }.to raise_error(OptionParser::InvalidOption)
14
14
  end
15
15
 
16
- it 'allows future parser, style, smoke, and regression checks to be enabled' do
17
- PuppetCheck.future_parser = false
18
- PuppetCheck.style_check = false
19
- PuppetCheck.smoke_check = false
20
- PuppetCheck.regression_check = false
21
- PuppetCheck::CLI.parse(%w(-s -f -r --smoke foo))
22
- expect(PuppetCheck.future_parser).to eql(true)
23
- expect(PuppetCheck.style_check).to eql(true)
24
- expect(PuppetCheck.smoke_check).to eql(true)
25
- expect(PuppetCheck.regression_check).to eql(true)
16
+ it 'allows future parser, fail on warnings, style, smoke, and regression checks to be enabled' do
17
+ PuppetCheck.settings[:future_parser] = false
18
+ PuppetCheck.settings[:fail_on_warnings] = false
19
+ PuppetCheck.settings[:style_check] = false
20
+ PuppetCheck.settings[:smoke_check] = false
21
+ PuppetCheck.settings[:regression_check] = false
22
+ PuppetCheck::CLI.parse(%w[-f --fail-on-warnings -s -r --smoke foo])
23
+ expect(PuppetCheck.settings[:future_parser]).to eql(true)
24
+ expect(PuppetCheck.settings[:fail_on_warnings]).to eql(true)
25
+ expect(PuppetCheck.settings[:style_check]).to eql(true)
26
+ expect(PuppetCheck.settings[:smoke_check]).to eql(true)
27
+ expect(PuppetCheck.settings[:regression_check]).to eql(true)
26
28
  end
27
29
 
28
30
  it 'correctly parses a formatting option' do
29
- PuppetCheck.output_format = ''
30
- PuppetCheck::CLI.parse(%w(-o text))
31
- expect(PuppetCheck.output_format).to eql('text')
31
+ PuppetCheck.settings[:output_format] = ''
32
+ PuppetCheck::CLI.parse(%w[-o text])
33
+ expect(PuppetCheck.settings[:output_format]).to eql('text')
32
34
  end
33
35
 
34
36
  it 'correctly parses octocatalog-diff options' do
35
- PuppetCheck.octoconfig = ''
36
- PuppetCheck.octonodes = []
37
- PuppetCheck::CLI.parse(%w(--octoconfig config.cfg.rb --octonodes server1,server2))
38
- expect(PuppetCheck.octoconfig).to eql('config.cfg.rb')
39
- expect(PuppetCheck.octonodes).to eql(%w(server1 server2))
37
+ PuppetCheck.settings[:octoconfig] = ''
38
+ PuppetCheck.settings[:octonodes] = []
39
+ PuppetCheck::CLI.parse(%w[--octoconfig config.cfg.rb --octonodes server1,server2])
40
+ expect(PuppetCheck.settings[:octoconfig]).to eql('config.cfg.rb')
41
+ expect(PuppetCheck.settings[:octonodes]).to eql(%w[server1 server2])
40
42
  end
41
43
 
42
44
  it 'correctly parses PuppetLint arguments' do
43
- PuppetCheck.puppetlint_args = []
44
- PuppetCheck::CLI.parse(%w(--puppet-lint puppetlint-arg-one,puppetlint-arg-two foo))
45
- expect(PuppetCheck.puppetlint_args).to eql(['--puppetlint-arg-one', '--puppetlint-arg-two'])
45
+ PuppetCheck.settings[:puppetlint_args] = []
46
+ PuppetCheck::CLI.parse(%w[--puppet-lint puppetlint-arg-one,puppetlint-arg-two foo])
47
+ expect(PuppetCheck.settings[:puppetlint_args]).to eql(['--puppetlint-arg-one', '--puppetlint-arg-two'])
46
48
  end
47
49
 
48
50
  it 'correctly loads a .puppet-lint.rc' do
49
- PuppetCheck.puppetlint_args = []
50
- PuppetCheck::CLI.parse(%W(-c #{fixtures_dir}/manifests/.puppet-lint.rc))
51
- expect(PuppetCheck.puppetlint_args).to eql(['--puppetlint-arg-one', '--puppetlint-arg-two'])
51
+ PuppetCheck.settings[:puppetlint_args] = []
52
+ PuppetCheck::CLI.parse(%W[-c #{fixtures_dir}/manifests/.puppet-lint.rc])
53
+ expect(PuppetCheck.settings[:puppetlint_args]).to eql(['--puppetlint-arg-one', '--puppetlint-arg-two'])
52
54
  end
53
55
 
54
56
  it 'correctly parses Rubocop arguments' do
55
- PuppetCheck.rubocop_args = []
56
- PuppetCheck::CLI.parse(%w(--rubocop rubocop-arg-one,rubocop-arg-two foo))
57
- expect(PuppetCheck.rubocop_args).to eql(['--except', 'rubocop-arg-one,rubocop-arg-two'])
57
+ PuppetCheck.settings[:rubocop_args] = []
58
+ PuppetCheck::CLI.parse(%w[--rubocop rubocop-arg-one,rubocop-arg-two foo])
59
+ expect(PuppetCheck.settings[:rubocop_args]).to eql(['--except', 'rubocop-arg-one,rubocop-arg-two'])
58
60
  end
59
61
 
60
62
  it 'correctly parses multiple sets of arguments' do
61
- PuppetCheck.future_parser = false
62
- PuppetCheck.style_check = false
63
- PuppetCheck.puppetlint_args = []
64
- PuppetCheck.rubocop_args = []
65
- PuppetCheck::CLI.parse(%w(-s -f --puppet-lint puppetlint-arg-one,puppetlint-arg-two --rubocop rubocop-arg-one,rubocop-arg-two foo))
66
- expect(PuppetCheck.future_parser).to eql(true)
67
- expect(PuppetCheck.style_check).to eql(true)
68
- expect(PuppetCheck.puppetlint_args).to eql(['--puppetlint-arg-one', '--puppetlint-arg-two'])
69
- expect(PuppetCheck.rubocop_args).to eql(['--except', 'rubocop-arg-one,rubocop-arg-two'])
63
+ PuppetCheck.settings[:future_parser] = false
64
+ PuppetCheck.settings[:style_check] = false
65
+ PuppetCheck.settings[:puppetlint_args] = []
66
+ PuppetCheck.settings[:rubocop_args] = []
67
+ PuppetCheck::CLI.parse(%w[-s -f --puppet-lint puppetlint-arg-one,puppetlint-arg-two --rubocop rubocop-arg-one,rubocop-arg-two foo])
68
+ expect(PuppetCheck.settings[:future_parser]).to eql(true)
69
+ expect(PuppetCheck.settings[:style_check]).to eql(true)
70
+ expect(PuppetCheck.settings[:puppetlint_args]).to eql(['--puppetlint-arg-one', '--puppetlint-arg-two'])
71
+ expect(PuppetCheck.settings[:rubocop_args]).to eql(['--except', 'rubocop-arg-one,rubocop-arg-two'])
70
72
  end
71
73
  end
72
74
  end
@@ -3,68 +3,68 @@ require_relative '../../lib/puppet-check/data_parser'
3
3
 
4
4
  describe DataParser do
5
5
  before(:each) do
6
- PuppetCheck.error_files = []
7
- PuppetCheck.warning_files = []
8
- PuppetCheck.clean_files = []
6
+ PuppetCheck.settings[:error_files] = []
7
+ PuppetCheck.settings[:warning_files] = []
8
+ PuppetCheck.settings[:clean_files] = []
9
9
  end
10
10
 
11
11
  context '.yaml' do
12
12
  it 'puts a bad syntax yaml file in the error files array' do
13
13
  DataParser.yaml([fixtures_dir + 'hieradata/syntax.yaml'])
14
- expect(PuppetCheck.error_files[0]).to match(%r{^#{fixtures_dir}hieradata/syntax.yaml:\nblock sequence entries are not allowed})
15
- expect(PuppetCheck.warning_files).to eql([])
16
- expect(PuppetCheck.clean_files).to eql([])
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
17
  end
18
18
  it 'puts a good yaml file with potential hiera issues in the warning files array' do
19
19
  DataParser.yaml([fixtures_dir + 'hieradata/style.yaml'])
20
- expect(PuppetCheck.error_files).to eql([])
21
- expect(PuppetCheck.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 will fail to parse it correctly})
22
- expect(PuppetCheck.clean_files).to eql([])
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 will fail to parse it correctly})
22
+ expect(PuppetCheck.settings[:clean_files]).to eql([])
23
23
  end
24
24
  it 'puts a good yaml file in the clean files array' do
25
25
  DataParser.yaml([fixtures_dir + 'hieradata/good.yaml'])
26
- expect(PuppetCheck.error_files).to eql([])
27
- expect(PuppetCheck.warning_files).to eql([])
28
- expect(PuppetCheck.clean_files).to eql(["#{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"])
29
29
  end
30
30
  end
31
31
 
32
32
  context '.json' do
33
33
  it 'puts a bad syntax json file in the error files array' do
34
34
  DataParser.json([fixtures_dir + 'hieradata/syntax.json'])
35
- expect(PuppetCheck.error_files[0]).to match(%r{^#{fixtures_dir}hieradata/syntax.json:\n.*unexpected token})
36
- expect(PuppetCheck.warning_files).to eql([])
37
- expect(PuppetCheck.clean_files).to eql([])
35
+ expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}hieradata/syntax.json:\n.*unexpected token})
36
+ expect(PuppetCheck.settings[:warning_files]).to eql([])
37
+ expect(PuppetCheck.settings[:clean_files]).to eql([])
38
38
  end
39
39
  it 'puts a bad metadata json file in the error files array' do
40
40
  DataParser.json([fixtures_dir + 'metadata_syntax/metadata.json'])
41
- expect(PuppetCheck.error_files[0]).to match(%r{^#{fixtures_dir}metadata_syntax/metadata.json:\nRequired field.*\nField 'requirements'.*\nDuplicate dependencies.*\nDeprecated field.*\nSummary exceeds})
42
- expect(PuppetCheck.warning_files).to eql([])
43
- expect(PuppetCheck.clean_files).to eql([])
41
+ 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})
42
+ expect(PuppetCheck.settings[:warning_files]).to eql([])
43
+ expect(PuppetCheck.settings[:clean_files]).to eql([])
44
44
  end
45
45
  it 'puts a bad style metadata json file in the warning files array' do
46
46
  DataParser.json([fixtures_dir + 'metadata_style/metadata.json'])
47
- expect(PuppetCheck.error_files).to eql([])
48
- expect(PuppetCheck.warning_files[0]).to match(%r{^#{fixtures_dir}metadata_style/metadata.json:\n'pe' is missing an upper bound.\n.*operatingsystem_support.*\nLicense identifier})
49
- expect(PuppetCheck.clean_files).to eql([])
47
+ expect(PuppetCheck.settings[:error_files]).to eql([])
48
+ 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})
49
+ expect(PuppetCheck.settings[:clean_files]).to eql([])
50
50
  end
51
51
  it 'puts another bad style metadata json file in the warning files array' do
52
52
  DataParser.json([fixtures_dir + 'metadata_style_two/metadata.json'])
53
- expect(PuppetCheck.error_files).to eql([])
54
- expect(PuppetCheck.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})
55
- expect(PuppetCheck.clean_files).to eql([])
53
+ expect(PuppetCheck.settings[:error_files]).to eql([])
54
+ 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})
55
+ expect(PuppetCheck.settings[:clean_files]).to eql([])
56
56
  end
57
57
  it 'puts a good json file in the clean files array' do
58
58
  DataParser.json([fixtures_dir + 'hieradata/good.json'])
59
- expect(PuppetCheck.error_files).to eql([])
60
- expect(PuppetCheck.warning_files).to eql([])
61
- expect(PuppetCheck.clean_files).to eql(["#{fixtures_dir}hieradata/good.json"])
59
+ expect(PuppetCheck.settings[:error_files]).to eql([])
60
+ expect(PuppetCheck.settings[:warning_files]).to eql([])
61
+ expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}hieradata/good.json"])
62
62
  end
63
63
  it 'puts a good metadata json file in the clean files array' do
64
64
  DataParser.json([fixtures_dir + 'metadata_good/metadata.json'])
65
- expect(PuppetCheck.error_files).to eql([])
66
- expect(PuppetCheck.warning_files).to eql([])
67
- expect(PuppetCheck.clean_files).to eql(["#{fixtures_dir}metadata_good/metadata.json"])
65
+ expect(PuppetCheck.settings[:error_files]).to eql([])
66
+ expect(PuppetCheck.settings[:warning_files]).to eql([])
67
+ expect(PuppetCheck.settings[:clean_files]).to eql(["#{fixtures_dir}metadata_good/metadata.json"])
68
68
  end
69
69
  end
70
70
  end