puppet-syntax 3.3.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,8 @@
1
1
  module PuppetSyntax
2
2
  class Manifests
3
3
  def check(filelist)
4
- raise "Expected an array of files" unless filelist.is_a?(Array)
4
+ raise 'Expected an array of files' unless filelist.is_a?(Array)
5
+
5
6
  require 'puppet'
6
7
  require 'puppet/version'
7
8
  require 'puppet/face'
@@ -21,14 +22,12 @@ module PuppetSyntax
21
22
  Puppet::Test::TestHelper.before_each_test
22
23
  begin
23
24
  error = validate_manifest(puppet_file)
24
- if error.is_a?(Hash) # Puppet 6.5.0 onwards
25
- output << error.values.first unless error.empty?
26
- end
25
+ output << error.values.first if error.is_a?(Hash) && !error.empty? # Puppet 6.5.0 onwards
27
26
  rescue SystemExit
28
27
  # Disregard exit(1) from face.
29
28
  # This is how puppet < 6.5.0 `validate_manifest` worked.
30
- rescue => error
31
- output << error
29
+ rescue StandardError => e
30
+ output << e
32
31
  ensure
33
32
  Puppet::Test::TestHelper.after_each_test
34
33
  end
@@ -38,30 +37,31 @@ module PuppetSyntax
38
37
  output.map! { |e| e.to_s }
39
38
 
40
39
  # Exported resources will raise warnings when outside a puppetmaster.
41
- output.reject! { |e|
40
+ output.reject! do |e|
42
41
  e =~ /^You cannot collect( exported resources)? without storeconfigs being set/
43
- }
42
+ end
44
43
 
45
44
  # tag and schedule parameters in class raise warnings notice in output that prevent from succeed
46
- output.reject! { |e|
45
+ output.reject! do |e|
47
46
  e =~ /^(tag|schedule) is a metaparam; this value will inherit to all contained resources in the /
48
- }
47
+ end
49
48
 
50
- deprecations = output.select { |e|
49
+ deprecations = output.select do |e|
51
50
  e =~ /^Deprecation notice:|is deprecated/
52
- }
51
+ end
53
52
 
54
53
  # Errors exist if there is any output that isn't a deprecation notice.
55
54
  has_errors = (output != deprecations)
56
55
 
57
- return output, has_errors
56
+ [output, has_errors]
58
57
  ensure
59
58
  Puppet::Test::TestHelper.after_all_tests if called_before_all_tests
60
59
  end
61
60
 
62
61
  private
62
+
63
63
  def validate_manifest(file)
64
- Puppet[:tasks] = true if Puppet::Util::Package.versioncmp(Puppet.version, '5.4.0') >= 0 and file.match(/.*plans\/.*\.pp$/)
64
+ Puppet[:tasks] = true if %r{.*plans/.*\.pp$}.match?(file)
65
65
  Puppet::Face[:parser, :current].validate(file)
66
66
  end
67
67
  end
@@ -25,9 +25,9 @@ module PuppetSyntax
25
25
  filelist(PuppetSyntax.hieradata_paths)
26
26
  end
27
27
 
28
- def initialize(*args)
29
- desc 'Syntax check Puppet manifests and templates'
30
- task :syntax => [
28
+ def initialize(*_args)
29
+ desc 'Syntax check for Puppet manifests, templates and Hiera'
30
+ task syntax: [
31
31
  'syntax:manifests',
32
32
  'syntax:templates',
33
33
  'syntax:hiera',
@@ -36,39 +36,40 @@ module PuppetSyntax
36
36
  namespace :syntax do
37
37
  desc 'Syntax check Puppet manifests'
38
38
  task :manifests do |t|
39
- $stderr.puts "---> #{t.name}"
39
+ warn "---> #{t.name}"
40
40
 
41
41
  c = PuppetSyntax::Manifests.new
42
42
  output, has_errors = c.check(filelist_manifests)
43
43
  $stdout.puts "#{output.join("\n")}\n" unless output.empty?
44
- exit 1 if has_errors || ( output.any? && PuppetSyntax.fail_on_deprecation_notices )
44
+ exit 1 if has_errors || (output.any? && PuppetSyntax.fail_on_deprecation_notices)
45
45
  end
46
46
 
47
47
  desc 'Syntax check Puppet templates'
48
48
  task :templates do |t|
49
- $stderr.puts "---> #{t.name}"
49
+ warn "---> #{t.name}"
50
50
 
51
51
  c = PuppetSyntax::Templates.new
52
52
  result = c.check(filelist_templates)
53
53
  unless result[:warnings].empty?
54
- $stdout.puts "WARNINGS:"
54
+ $stdout.puts 'WARNINGS:'
55
55
  $stdout.puts result[:warnings].join("\n")
56
56
  end
57
57
  unless result[:errors].empty?
58
- $stderr.puts "ERRORS:"
59
- $stderr.puts result[:errors].join("\n")
58
+ warn 'ERRORS:'
59
+ warn result[:errors].join("\n")
60
60
  exit 1
61
61
  end
62
62
  end
63
63
 
64
64
  desc 'Syntax check Hiera config files'
65
- task :hiera => [
65
+ task hiera: [
66
66
  'syntax:hiera:yaml',
67
67
  ]
68
68
 
69
69
  namespace :hiera do
70
70
  task :yaml do |t|
71
- $stderr.puts "---> #{t.name}"
71
+ warn "---> #{t.name}"
72
+ warn "#{t.name} was called, but PuppetSyntax.check_hiera_keys is false. hiera syntax won't be checked" unless PuppetSyntax.check_hiera_keys
72
73
  c = PuppetSyntax::Hiera.new
73
74
  errors = c.check(filelist_hiera_yaml)
74
75
  $stdout.puts "#{errors.join("\n")}\n" unless errors.empty?
@@ -4,10 +4,10 @@ require 'stringio'
4
4
  module PuppetSyntax
5
5
  class Templates
6
6
  def check(filelist)
7
- raise "Expected an array of files" unless filelist.is_a?(Array)
7
+ raise 'Expected an array of files' unless filelist.is_a?(Array)
8
8
 
9
9
  # We now have to redirect STDERR in order to capture warnings.
10
- $stderr = warnings = StringIO.new()
10
+ $stderr = warnings = StringIO.new
11
11
  result = { warnings: [], errors: [] }
12
12
 
13
13
  filelist.each do |file|
@@ -16,7 +16,7 @@ module PuppetSyntax
16
16
  elsif File.extname(file) == '.erb'
17
17
  tmp = validate_erb(file)
18
18
  end
19
- result.merge!(tmp) { |k, a, b| a.concat(b) } unless tmp.nil?
19
+ result.merge!(tmp) { |_k, a, b| a.concat(b) } unless tmp.nil?
20
20
  end
21
21
 
22
22
  $stderr = STDERR
@@ -29,12 +29,11 @@ module PuppetSyntax
29
29
  end
30
30
 
31
31
  def validate_epp(filename)
32
- require 'puppet/error'
33
- require 'puppet/pops'
32
+ require 'puppet'
34
33
  result = { warnings: [], errors: [] }
35
34
  formatter = Puppet::Pops::Validation::DiagnosticFormatterPuppetStyle.new
36
- evaluating_parser = Puppet::Pops::Parser::EvaluatingParser::EvaluatingEppParser.new()
37
- parser = evaluating_parser.parser()
35
+ evaluating_parser = Puppet::Pops::Parser::EvaluatingParser::EvaluatingEppParser.new
36
+ parser = evaluating_parser.parser
38
37
  begin
39
38
  parse_result = parser.parse_file(filename)
40
39
  validation_result = evaluating_parser.validate(parse_result.model)
@@ -56,10 +55,10 @@ module PuppetSyntax
56
55
  column = err.source_pos.pos
57
56
  result[:errors] << "#{file}:#{line}:#{column}: #{message}"
58
57
  end
59
- rescue Puppet::ParseError, SyntaxError => exc
60
- result[:errors] << exc
61
- rescue => exc
62
- result[:errors] << exc
58
+ rescue Puppet::ParseError, SyntaxError => e
59
+ result[:errors] << e
60
+ rescue StandardError => e
61
+ result[:errors] << e
63
62
  end
64
63
 
65
64
  result
@@ -73,18 +72,18 @@ module PuppetSyntax
73
72
  erb = if RUBY_VERSION >= '2.6'
74
73
  ERB.new(template, trim_mode: '-')
75
74
  else
76
- ERB.new(template, nil, '-')
75
+ ERB.new(template, trim_mode: '-')
77
76
  end
78
77
  erb.filename = filename
79
78
  erb.result
80
- rescue NameError => error
79
+ rescue NameError => e
81
80
  # This is normal because we don't have the variables that would
82
81
  # ordinarily be bound by the parent Puppet manifest.
83
82
  rescue TypeError
84
83
  # This is normal because we don't have the variables that would
85
84
  # ordinarily be bound by the parent Puppet manifest.
86
- rescue SyntaxError => error
87
- result[:errors] << error
85
+ rescue SyntaxError => e
86
+ result[:errors] << e
88
87
  end
89
88
 
90
89
  result
@@ -1,3 +1,3 @@
1
1
  module PuppetSyntax
2
- VERSION = '3.3.0'
2
+ VERSION = '4.0.1'
3
3
  end
data/lib/puppet-syntax.rb CHANGED
@@ -1,4 +1,4 @@
1
- require "puppet-syntax/version"
1
+ require 'puppet-syntax/version'
2
2
 
3
3
  module PuppetSyntax
4
4
  autoload :Hiera, 'puppet-syntax/hiera'
@@ -7,16 +7,16 @@ module PuppetSyntax
7
7
 
8
8
  @exclude_paths = []
9
9
  @hieradata_paths = [
10
- "**/data/**/*.*{yaml,yml}",
11
- "hieradata/**/*.*{yaml,yml}",
12
- "hiera*.*{yaml,yml}"
10
+ '**/data/**/*.*{yaml,yml}',
11
+ 'hieradata/**/*.*{yaml,yml}',
12
+ 'hiera*.*{yaml,yml}',
13
13
  ]
14
14
  @manifests_paths = [
15
- '**/*.pp'
15
+ '**/*.pp',
16
16
  ]
17
17
  @templates_paths = [
18
18
  '**/templates/**/*.erb',
19
- '**/templates/**/*.epp'
19
+ '**/templates/**/*.epp',
20
20
  ]
21
21
  @fail_on_deprecation_notices = true
22
22
  @check_hiera_keys = false
@@ -1,28 +1,28 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'puppet-syntax/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "puppet-syntax"
6
+ spec.name = 'puppet-syntax'
8
7
  spec.version = PuppetSyntax::VERSION
9
- spec.authors = ["Vox Pupuli"]
10
- spec.email = ["voxpupuli@groups.io"]
11
- spec.description = %q{Syntax checks for Puppet manifests and templates}
12
- spec.summary = %q{Syntax checks for Puppet manifests, templates, and Hiera YAML}
13
- spec.homepage = "https://github.com/voxpupuli/puppet-syntax"
14
- spec.license = "MIT"
8
+ spec.authors = ['Vox Pupuli']
9
+ spec.email = ['voxpupuli@groups.io']
10
+ spec.description = 'Syntax checks for Puppet manifests and templates'
11
+ spec.summary = 'Syntax checks for Puppet manifests, templates, and Hiera YAML'
12
+ spec.homepage = 'https://github.com/voxpupuli/puppet-syntax'
13
+ spec.license = 'MIT'
15
14
 
16
15
  spec.files = `git ls-files`.split($/)
17
16
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
17
+ spec.require_paths = ['lib']
20
18
 
21
- spec.required_ruby_version = ">= 2.4"
19
+ spec.required_ruby_version = '>= 2.7'
22
20
 
23
- spec.add_dependency "rake"
24
- spec.add_dependency "puppet", ">= 5"
21
+ spec.add_dependency 'puppet', '>= 7', '< 9'
22
+ spec.add_dependency 'rake', '~> 13.1'
25
23
 
26
- spec.add_development_dependency "pry"
27
- spec.add_development_dependency "rb-readline"
24
+ spec.add_development_dependency 'pry', '~> 0.14.2'
25
+ spec.add_development_dependency 'rb-readline', '~> 0.5.5'
26
+
27
+ spec.add_development_dependency 'voxpupuli-rubocop', '~> 2.5.0'
28
28
  end
@@ -3,31 +3,30 @@ require 'spec_helper'
3
3
  describe PuppetSyntax::Hiera do
4
4
  let(:subject) { PuppetSyntax::Hiera.new }
5
5
 
6
- it 'should expect an array of files' do
6
+ it 'expects an array of files' do
7
7
  expect { subject.check(nil) }.to raise_error(/Expected an array of files/)
8
8
  end
9
9
 
10
- it "should return nothing from valid YAML" do
10
+ it 'returns nothing from valid YAML' do
11
11
  files = fixture_hiera('hiera_good.yaml')
12
12
  res = subject.check(files)
13
- expect(res).to be == []
13
+ expect(res).to eq []
14
14
  end
15
15
 
16
- it "should return an error from invalid YAML" do
17
- hiera_yaml = RUBY_VERSION =~ /1.8/ ? 'hiera_bad_18.yaml' : 'hiera_bad.yaml'
18
- files = fixture_hiera(hiera_yaml)
16
+ it 'returns an error from invalid YAML' do
17
+ files = fixture_hiera('hiera_bad.yaml')
19
18
  expected = /ERROR: Failed to parse #{files[0]}:/
20
19
  res = subject.check(files)
21
- expect(res.size).to be == 1
20
+ expect(res.size).to eq 1
22
21
  expect(res.first).to match(expected)
23
22
  end
24
23
 
25
24
  context 'check_hiera_keys = true' do
26
- before(:each) {
25
+ before do
27
26
  PuppetSyntax.check_hiera_keys = true
28
- }
27
+ end
29
28
 
30
- it "should return warnings for invalid keys" do
29
+ it 'returns warnings for invalid keys' do
31
30
  hiera_yaml = 'hiera_badkey.yaml'
32
31
  examples = 5
33
32
  files = fixture_hiera(hiera_yaml)
@@ -35,7 +34,7 @@ describe PuppetSyntax::Hiera do
35
34
  (1..examples).each do |n|
36
35
  expect(res).to include(/::warning#{n}/)
37
36
  end
38
- expect(res.size).to be == examples
37
+ expect(res.size).to eq examples
39
38
  expect(res[0]).to match('Key :typical:typo::warning1: Looks like a missing colon')
40
39
  expect(res[1]).to match('Key ::notsotypical::warning2: Puppet automatic lookup will not use leading \'::\'')
41
40
  expect(res[2]).to match('Key :noCamelCase::warning3: Not a valid Puppet variable name for automatic lookup')
@@ -43,7 +42,7 @@ describe PuppetSyntax::Hiera do
43
42
  expect(res[4]).to match('Key :picky::warning5: Puppet automatic lookup will not look up symbols')
44
43
  end
45
44
 
46
- it "should return warnings for bad eyaml values" do
45
+ it 'returns warnings for bad eyaml values' do
47
46
  hiera_yaml = 'hiera_bad.eyaml'
48
47
  examples = 6
49
48
  files = fixture_hiera(hiera_yaml)
@@ -51,7 +50,7 @@ describe PuppetSyntax::Hiera do
51
50
  (1..examples).each do |n|
52
51
  expect(res).to include(/::warning#{n}/)
53
52
  end
54
- expect(res.size).to be == examples
53
+ expect(res.size).to eq examples
55
54
  expect(res[0]).to match('Key acme::warning1 has unknown eyaml method unknown-method')
56
55
  expect(res[1]).to match('Key acme::warning2 has unterminated eyaml value')
57
56
  expect(res[2]).to match('Key acme::warning3 has unpadded or truncated base64 data')
@@ -60,12 +59,11 @@ describe PuppetSyntax::Hiera do
60
59
  expect(res[5]).to match('Key acme::warning6\[\'hash_key\'\]\[2\] has corrupt base64 data')
61
60
  end
62
61
 
63
- it "should handle empty files" do
62
+ it 'handles empty files' do
64
63
  hiera_yaml = 'hiera_key_empty.yaml'
65
64
  files = fixture_hiera(hiera_yaml)
66
65
  res = subject.check(files)
67
66
  expect(res).to be_empty
68
67
  end
69
-
70
68
  end
71
69
  end
@@ -4,11 +4,11 @@ require 'puppet'
4
4
  describe PuppetSyntax::Manifests do
5
5
  let(:subject) { PuppetSyntax::Manifests.new }
6
6
 
7
- it 'should expect an array of files' do
7
+ it 'expects an array of files' do
8
8
  expect { subject.check(nil) }.to raise_error(/Expected an array of files/)
9
9
  end
10
10
 
11
- it 'should return nothing from a valid file' do
11
+ it 'returns nothing from a valid file' do
12
12
  files = fixture_manifests('pass.pp')
13
13
  output, has_errors = subject.check(files)
14
14
 
@@ -16,7 +16,7 @@ describe PuppetSyntax::Manifests do
16
16
  expect(has_errors).to eq(false)
17
17
  end
18
18
 
19
- it 'should return nothing from a valid file with a class using tag parameter' do
19
+ it 'returns nothing from a valid file with a class using tag parameter' do
20
20
  files = fixture_manifests('tag_notice.pp')
21
21
  output, has_errors = subject.check(files)
22
22
 
@@ -24,7 +24,7 @@ describe PuppetSyntax::Manifests do
24
24
  expect(has_errors).to eq(false)
25
25
  end
26
26
 
27
- it 'should return nothing from a valid file with a class using schedule parameter' do
27
+ it 'returns nothing from a valid file with a class using schedule parameter' do
28
28
  files = fixture_manifests('schedule_notice.pp')
29
29
  output, has_errors = subject.check(files)
30
30
 
@@ -32,7 +32,7 @@ describe PuppetSyntax::Manifests do
32
32
  expect(has_errors).to eq(false)
33
33
  end
34
34
 
35
- it 'should return an error from an invalid file' do
35
+ it 'returns an error from an invalid file' do
36
36
  files = fixture_manifests('fail_error.pp')
37
37
  output, has_errors = subject.check(files)
38
38
 
@@ -41,7 +41,7 @@ describe PuppetSyntax::Manifests do
41
41
  expect(has_errors).to eq(true)
42
42
  end
43
43
 
44
- it 'should return a warning from an invalid file' do
44
+ it 'returns a warning from an invalid file' do
45
45
  files = fixture_manifests('fail_warning.pp')
46
46
  output, has_errors = subject.check(files)
47
47
 
@@ -52,16 +52,15 @@ describe PuppetSyntax::Manifests do
52
52
  expect(output[1]).to match(/Unrecogni(s|z)ed escape sequence '\\\]'/)
53
53
  end
54
54
 
55
- it 'should ignore warnings about storeconfigs' do
55
+ it 'ignores warnings about storeconfigs' do
56
56
  files = fixture_manifests('pass_storeconfigs.pp')
57
57
  output, has_errors = subject.check(files)
58
58
 
59
59
  expect(output).to eq([])
60
60
  expect(has_errors).to eq(false)
61
-
62
61
  end
63
62
 
64
- it 'should read more than one valid file' do
63
+ it 'reads more than one valid file' do
65
64
  files = fixture_manifests(['pass.pp', 'pass_storeconfigs.pp'])
66
65
  output, has_errors = subject.check(files)
67
66
 
@@ -69,27 +68,27 @@ describe PuppetSyntax::Manifests do
69
68
  expect(has_errors).to eq(false)
70
69
  end
71
70
 
72
- it 'should continue after finding an error in the first file' do
71
+ it 'continues after finding an error in the first file' do
73
72
  files = fixture_manifests(['fail_error.pp', 'fail_warning.pp'])
74
73
  output, has_errors = subject.check(files)
75
74
 
76
75
  expect(has_errors).to eq(true)
77
76
  expect(output.size).to eq(5)
78
- expect(output[0]).to match(/This Name has no effect. A Host Class Definition can not end with a value-producing expression without other effect \(file: \S*\/fail_error.pp, line: 2, column: 32\)$/)
79
- expect(output[1]).to match(/This Name has no effect. A value was produced and then forgotten \(one or more preceding expressions may have the wrong form\) \(file: \S*\/fail_error.pp, line: 2, column: 3\)$/)
77
+ expect(output[0]).to match(%r{This Name has no effect. A Host Class Definition can not end with a value-producing expression without other effect \(file: \S*/fail_error.pp, line: 2, column: 32\)$})
78
+ expect(output[1]).to match(%r{This Name has no effect. A value was produced and then forgotten \(one or more preceding expressions may have the wrong form\) \(file: \S*/fail_error.pp, line: 2, column: 3\)$})
80
79
  expect(output[2]).to match('2 errors. Giving up')
81
80
  expect(output[3]).to match(/Unrecogni(s|z)ed escape sequence '\\\['/)
82
81
  expect(output[4]).to match(/Unrecogni(s|z)ed escape sequence '\\\]'/)
83
82
  end
84
83
 
85
84
  describe 'deprecation notices' do
86
- it 'should instead be failures' do
85
+ it 'insteads be failures' do
87
86
  files = fixture_manifests('deprecation_notice.pp')
88
87
  output, has_errors = subject.check(files)
89
88
 
90
89
  expect(has_errors).to eq(true)
91
90
  expect(output.size).to eq(1)
92
- expect(output[0]).to match (/Node inheritance is not supported in Puppet >= 4.0.0/)
91
+ expect(output[0]).to match(/Node inheritance is not supported in Puppet >= 4.0.0/)
93
92
  end
94
93
  end
95
94
  end
@@ -9,25 +9,25 @@ known_yaml_subdir = 'spec/fixtures/hiera/data/test/hiera_3.yaml'
9
9
  known_eyaml_subdir = 'spec/fixtures/hiera/data/test/hiera_4.eyaml'
10
10
 
11
11
  describe 'PuppetSyntax rake tasks' do
12
- it 'should filter directories' do
12
+ it 'filters directories' do
13
13
  list = PuppetSyntax::RakeTask.new.filelist(['**/lib', known_pp])
14
14
  expect(list.count).to eq 1
15
15
  expect(list).to include(known_pp)
16
16
  end
17
17
 
18
- it 'should generate FileList of manifests relative to Rakefile' do
18
+ it 'generates FileList of manifests relative to Rakefile' do
19
19
  list = PuppetSyntax::RakeTask.new.filelist_manifests
20
20
  expect(list).to include(known_pp)
21
21
  expect(list.count).to eq 9
22
22
  end
23
23
 
24
- it 'should generate FileList of templates relative to Rakefile' do
24
+ it 'generates FileList of templates relative to Rakefile' do
25
25
  list = PuppetSyntax::RakeTask.new.filelist_templates
26
26
  expect(list).to include(known_erb)
27
27
  expect(list.count).to eq 9
28
28
  end
29
29
 
30
- it 'should generate FileList of Hiera yaml files relative to Rakefile' do
30
+ it 'generates FileList of Hiera yaml files relative to Rakefile' do
31
31
  list = PuppetSyntax::RakeTask.new.filelist_hiera_yaml
32
32
  expect(list).to include(known_yaml)
33
33
  expect(list).to include(known_eyaml)
@@ -4,17 +4,17 @@ describe PuppetSyntax::Templates do
4
4
  let(:subject) { PuppetSyntax::Templates.new }
5
5
  let(:conditional_warning_regex) do
6
6
  if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6.0')
7
- %r{2: warning: found `= literal' in conditional}
7
+ /2: warning: found `= literal' in conditional/
8
8
  else
9
- %r{2: warning: found = in conditional}
9
+ /2: warning: found = in conditional/
10
10
  end
11
11
  end
12
12
 
13
- it 'should expect an array of files' do
13
+ it 'expects an array of files' do
14
14
  expect { subject.check(nil) }.to raise_error(/Expected an array of files/)
15
15
  end
16
16
 
17
- it 'should return nothing from a valid file' do
17
+ it 'returns nothing from a valid file' do
18
18
  files = fixture_templates('pass.erb')
19
19
  res = subject.check(files)
20
20
 
@@ -22,7 +22,7 @@ describe PuppetSyntax::Templates do
22
22
  expect(res[:errors]).to match([])
23
23
  end
24
24
 
25
- it 'should ignore NameErrors from unbound variables' do
25
+ it 'ignores NameErrors from unbound variables' do
26
26
  files = fixture_templates('pass_unbound_var.erb')
27
27
  res = subject.check(files)
28
28
 
@@ -30,7 +30,7 @@ describe PuppetSyntax::Templates do
30
30
  expect(res[:errors]).to match([])
31
31
  end
32
32
 
33
- it 'should catch SyntaxError' do
33
+ it 'catches SyntaxError' do
34
34
  files = fixture_templates('fail_error.erb')
35
35
  res = subject.check(files)
36
36
 
@@ -38,7 +38,7 @@ describe PuppetSyntax::Templates do
38
38
  expect(res[:errors][0]).to match(/2: syntax error, unexpected/)
39
39
  end
40
40
 
41
- it 'should catch Ruby warnings' do
41
+ it 'catches Ruby warnings' do
42
42
  files = fixture_templates('fail_warning.erb')
43
43
  res = subject.check(files)
44
44
 
@@ -46,7 +46,7 @@ describe PuppetSyntax::Templates do
46
46
  expect(res[:warnings][0]).to match(conditional_warning_regex)
47
47
  end
48
48
 
49
- it 'should read more than one valid file' do
49
+ it 'reads more than one valid file' do
50
50
  files = fixture_templates(['pass.erb', 'pass_unbound_var.erb'])
51
51
  res = subject.check(files)
52
52
 
@@ -54,7 +54,7 @@ describe PuppetSyntax::Templates do
54
54
  expect(res[:errors]).to match([])
55
55
  end
56
56
 
57
- it 'should continue after finding an error in the first file' do
57
+ it 'continues after finding an error in the first file' do
58
58
  files = fixture_templates(['fail_error.erb', 'fail_warning.erb'])
59
59
  res = subject.check(files)
60
60
 
@@ -64,7 +64,7 @@ describe PuppetSyntax::Templates do
64
64
  expect(res[:warnings][0]).to match(conditional_warning_regex)
65
65
  end
66
66
 
67
- it 'should ignore a TypeError' do
67
+ it 'ignores a TypeError' do
68
68
  files = fixture_templates('typeerror_shouldwin.erb')
69
69
  res = subject.check(files)
70
70
 
@@ -72,7 +72,7 @@ describe PuppetSyntax::Templates do
72
72
  expect(res[:errors]).to match([])
73
73
  end
74
74
 
75
- it 'should ignore files without .erb extension' do
75
+ it 'ignores files without .erb extension' do
76
76
  files = fixture_templates('ignore.tpl')
77
77
  res = subject.check(files)
78
78
 
@@ -80,7 +80,7 @@ describe PuppetSyntax::Templates do
80
80
  expect(res[:errors]).to match([])
81
81
  end
82
82
 
83
- it 'should return nothing from a valid file' do
83
+ it 'returns nothing from a valid file' do
84
84
  files = fixture_templates('pass.epp')
85
85
  res = subject.check(files)
86
86
 
@@ -88,7 +88,7 @@ describe PuppetSyntax::Templates do
88
88
  expect(res[:errors]).to match([])
89
89
  end
90
90
 
91
- it 'should catch SyntaxError' do
91
+ it 'catches SyntaxError' do
92
92
  files = fixture_templates('fail_error.epp')
93
93
  res = subject.check(files)
94
94
 
@@ -96,7 +96,7 @@ describe PuppetSyntax::Templates do
96
96
  expect(res[:errors][0]).to match(/This Type-Name has no effect/)
97
97
  end
98
98
 
99
- it 'should read more than one valid file' do
99
+ it 'reads more than one valid file' do
100
100
  files = fixture_templates(['pass.epp', 'pass_also.epp'])
101
101
  res = subject.check(files)
102
102
 
@@ -104,7 +104,7 @@ describe PuppetSyntax::Templates do
104
104
  expect(res[:errors]).to match([])
105
105
  end
106
106
 
107
- it 'should continue after finding an error in the first file' do
107
+ it 'continues after finding an error in the first file' do
108
108
  files = fixture_templates(['fail_error.epp', 'fail_error_also.epp'])
109
109
  res = subject.check(files)
110
110
 
@@ -114,11 +114,11 @@ describe PuppetSyntax::Templates do
114
114
  end
115
115
 
116
116
  context "when the 'epp_only' options is set" do
117
- before(:each) {
117
+ before do
118
118
  PuppetSyntax.epp_only = true
119
- }
119
+ end
120
120
 
121
- it 'should process an ERB as EPP and find an error' do
121
+ it 'processes an ERB as EPP and find an error' do
122
122
  files = fixture_templates('pass.erb')
123
123
  res = subject.check(files)
124
124