puppetlabs_spec_helper 5.0.3 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -112,7 +112,7 @@ task :parallel_spec_standalone do |_t, args|
112
112
  else
113
113
 
114
114
  args = ['-t', 'rspec']
115
- args.push('--').concat(ENV['CI_SPEC_OPTIONS'].strip.split(' ')).push('--') unless ENV['CI_SPEC_OPTIONS'].nil? || ENV['CI_SPEC_OPTIONS'].strip.empty?
115
+ args.push('--').concat(ENV['CI_SPEC_OPTIONS'].strip.split).push('--') unless ENV['CI_SPEC_OPTIONS'].nil? || ENV['CI_SPEC_OPTIONS'].strip.empty?
116
116
  args.concat(Rake::FileList[pattern].to_a)
117
117
 
118
118
  ParallelTests::CLI.new.run(args)
@@ -165,14 +165,14 @@ PuppetLint.configuration.ignore_paths << 'spec/**/*.pp'
165
165
  PuppetLint.configuration.ignore_paths << 'tests/**/*.pp'
166
166
  PuppetLint.configuration.ignore_paths << 'types/**/*.pp'
167
167
  PuppetLint.configuration.ignore_paths << 'vendor/**/*.pp'
168
- puppet_lint_disable_checks = [
169
- '80chars',
170
- '140chars',
171
- 'class_inherits_from_params_class',
172
- 'class_parameter_defaults',
173
- 'disable_autoloader_layout',
174
- 'documentation',
175
- 'single_quote_string_with_variables',
168
+ puppet_lint_disable_checks = %w[
169
+ 80chars
170
+ 140chars
171
+ class_inherits_from_params_class
172
+ class_parameter_defaults
173
+ disable_autoloader_layout
174
+ documentation
175
+ single_quote_string_with_variables
176
176
  ]
177
177
 
178
178
  puppet_lint_disable_checks.each do |check|
@@ -227,7 +227,7 @@ task :compute_dev_version do
227
227
  version = modinfo['version']
228
228
  elsif File.exist?('Modulefile')
229
229
  modfile = File.read('Modulefile')
230
- version = modfile.match(%r{\nversion +['"](.*)['"]})[1]
230
+ version = modfile.match(/\nversion +['"](.*)['"]/)[1]
231
231
  else
232
232
  raise 'Could not find a metadata.json or Modulefile! Cannot compute dev version without one or the other!'
233
233
  end
@@ -239,11 +239,11 @@ task :compute_dev_version do
239
239
  # If the branch is a release branch we append an 'r' into the new_version,
240
240
  # this is due to the release branch buildID conflicting with main branch when trying to push to the staging forge.
241
241
  # More info can be found at https://tickets.puppetlabs.com/browse/FM-6170
242
- new_version = if (build = ENV['BUILD_NUMBER'])
242
+ new_version = if (build = ENV.fetch('BUILD_NUMBER', nil))
243
243
  if branch.eql? 'release'
244
- '%s-%s%04d-%s' % [version, 'r', build, sha] # legacy support code # rubocop:disable Style/FormatStringToken
244
+ format('%s-%s%04d-%s', version, 'r', build, sha) # legacy support code
245
245
  else
246
- '%s-%04d-%s' % [version, build, sha] # legacy support code # rubocop:disable Style/FormatStringToken
246
+ format('%s-%04d-%s', version, build, sha) # legacy support code
247
247
  end
248
248
  else
249
249
  "#{version}-#{sha}"
@@ -321,9 +321,7 @@ begin
321
321
  # Use Rubocop's Github Actions formatter if possible
322
322
  if ENV['GITHUB_ACTIONS'] == 'true'
323
323
  rubocop_spec = Gem::Specification.find_by_name('rubocop')
324
- if Gem::Version.new(rubocop_spec.version) >= Gem::Version.new('1.2')
325
- task.formatters << 'github'
326
- end
324
+ task.formatters << 'github' if Gem::Version.new(rubocop_spec.version) >= Gem::Version.new('1.2')
327
325
  end
328
326
  end
329
327
  rescue LoadError
@@ -365,9 +363,7 @@ def create_gch_task(changelog_user = nil, changelog_project = nil, changelog_sin
365
363
  # rubocop:enable Lint/NestedMethodDefinition
366
364
 
367
365
  GitHubChangelogGenerator::RakeTask.new :changelog do |config|
368
- if ENV['CHANGELOG_GITHUB_TOKEN'].nil?
369
- raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'"
370
- end
366
+ raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if ENV['CHANGELOG_GITHUB_TOKEN'].nil?
371
367
 
372
368
  config.user = changelog_user || changelog_user_from_metadata
373
369
  config.project = changelog_project || changelog_project_from_metadata
@@ -383,16 +379,16 @@ def create_gch_task(changelog_user = nil, changelog_project = nil, changelog_sin
383
379
  config.configure_sections = {
384
380
  'Changed' => {
385
381
  'prefix' => '### Changed',
386
- 'labels' => ['backwards-incompatible'],
382
+ 'labels' => ['backwards-incompatible']
387
383
  },
388
384
  'Added' => {
389
385
  'prefix' => '### Added',
390
- 'labels' => ['feature', 'enhancement'],
386
+ 'labels' => %w[feature enhancement]
391
387
  },
392
388
  'Fixed' => {
393
389
  'prefix' => '### Fixed',
394
- 'labels' => ['bugfix'],
395
- },
390
+ 'labels' => ['bugfix']
391
+ }
396
392
  }
397
393
  end
398
394
  else
@@ -9,12 +9,12 @@ module PuppetlabsSpecHelper
9
9
  DEFAULT_IGNORED = [
10
10
  '/.git/',
11
11
  '/.bundle/',
12
- '/vendor/',
12
+ '/vendor/'
13
13
  ].freeze
14
14
 
15
15
  IGNORE_LIST_FILES = [
16
16
  '.pdkignore',
17
- '.gitignore',
17
+ '.gitignore'
18
18
  ].freeze
19
19
 
20
20
  def check(dir = Dir.pwd)
@@ -26,7 +26,7 @@ module PuppetlabsSpecHelper
26
26
 
27
27
  if child.symlink?
28
28
  results << child
29
- elsif child.directory? && child.basename.to_s !~ %r{^(\.git|\.?bundle)$}
29
+ elsif child.directory? && child.basename.to_s !~ /^(\.git|\.?bundle)$/
30
30
  results.concat(check(child))
31
31
  end
32
32
  end
@@ -107,9 +107,7 @@ module PuppetlabsSpecHelper
107
107
 
108
108
  fixtures = fixtures['fixtures']
109
109
 
110
- if fixtures['symlinks'].nil?
111
- fixtures['symlinks'] = auto_symlink
112
- end
110
+ fixtures['symlinks'] = auto_symlink if fixtures['symlinks'].nil?
113
111
 
114
112
  result = {}
115
113
  if fixtures.include?(category) && !fixtures[category].nil?
@@ -117,16 +115,12 @@ module PuppetlabsSpecHelper
117
115
 
118
116
  # load defaults from the `.fixtures.yml` `defaults` section
119
117
  # for the requested category and merge them into my defaults
120
- if fixture_defaults.include? category
121
- defaults = defaults.merge(fixture_defaults[category])
122
- end
118
+ defaults = defaults.merge(fixture_defaults[category]) if fixture_defaults.include? category
123
119
 
124
120
  fixtures[category].each do |fixture, opts|
125
121
  # convert a simple string fixture to a hash, by
126
122
  # using the string fixture as the `repo` option of the hash.
127
- if opts.instance_of?(String)
128
- opts = { 'repo' => opts }
129
- end
123
+ opts = { 'repo' => opts } if opts.instance_of?(String)
130
124
  # there should be a warning or something if it's not a hash...
131
125
  next unless opts.instance_of?(Hash)
132
126
 
@@ -136,8 +130,6 @@ module PuppetlabsSpecHelper
136
130
 
137
131
  next unless include_repo?(opts['puppet_version'])
138
132
 
139
- # rubocop:disable Security/Eval
140
- # TODO: Remove eval
141
133
  real_target = eval("\"#{opts['target']}\"", binding, __FILE__, __LINE__) # evaluating target reference in this context (see auto_symlink)
142
134
  real_source = eval("\"#{opts['repo']}\"", binding, __FILE__, __LINE__) # evaluating repo reference in this context (see auto_symlink)
143
135
 
@@ -194,9 +186,7 @@ module PuppetlabsSpecHelper
194
186
  raise "Unfortunately #{scm} is not supported yet"
195
187
  end
196
188
  result = system("#{scm} #{args.flatten.join ' '}")
197
- unless File.exist?(target)
198
- raise "Failed to clone #{scm} repository #{remote} into #{target}"
199
- end
189
+ raise "Failed to clone #{scm} repository #{remote} into #{target}" unless File.exist?(target)
200
190
 
201
191
  result
202
192
  end
@@ -251,10 +241,11 @@ module PuppetlabsSpecHelper
251
241
 
252
242
  def remove_subdirectory(target, subdir)
253
243
  return if subdir.nil?
244
+
254
245
  Dir.mktmpdir do |tmpdir|
255
- FileUtils.mv(Dir.glob("#{target}/#{subdir}/{.[^\.]*,*}"), tmpdir)
246
+ FileUtils.mv(Dir.glob("#{target}/#{subdir}/{.[^.]*,*}"), tmpdir)
256
247
  FileUtils.rm_rf("#{target}/#{subdir}")
257
- FileUtils.mv(Dir.glob("#{tmpdir}/{.[^\.]*,*}"), target.to_s)
248
+ FileUtils.mv(Dir.glob("#{tmpdir}/{.[^.]*,*}"), target.to_s)
258
249
  end
259
250
  end
260
251
 
@@ -319,7 +310,7 @@ module PuppetlabsSpecHelper
319
310
  # the last thread started should be the longest wait
320
311
  # Rubocop seems to push towards using select here.. however the implementation today relies on the result being
321
312
  # an array. Select returns a hash which makes it unsuitable so we need to use find_all.last.
322
- item, item_opts = items.find_all { |_i, o| o.key?(:thread) }.last # rubocop:disable Performance/Detect, Style/CollectionMethods
313
+ item, item_opts = items.find_all { |_i, o| o.key?(:thread) }.last # rubocop:disable Performance/Detect
323
314
  logger.debug "Waiting on #{item}"
324
315
  item_opts[:thread].join # wait for the thread to finish
325
316
  # now that we waited lets try again
@@ -395,14 +386,12 @@ module PuppetlabsSpecHelper
395
386
  # so we randomize the directory instead.
396
387
  # Does working_dir even need to be passed?
397
388
  Dir.mktmpdir do |working_dir|
398
- command = "puppet module install#{ref}#{flags} --ignore-dependencies" \
399
- ' --force' \
400
- " --module_working_dir \"#{working_dir}\"" \
401
- " --target-dir \"#{module_target_dir}\" \"#{remote}\""
389
+ command = "puppet module install#{ref}#{flags} --ignore-dependencies " \
390
+ '--force ' \
391
+ "--module_working_dir \"#{working_dir}\" " \
392
+ "--target-dir \"#{module_target_dir}\" \"#{remote}\""
402
393
 
403
- unless system(command)
404
- raise "Failed to install module #{remote} to #{module_target_dir}"
405
- end
394
+ raise "Failed to install module #{remote} to #{module_target_dir}" unless system(command)
406
395
  end
407
396
  $CHILD_STATUS.success?
408
397
  end
@@ -453,9 +442,7 @@ task :spec_clean do
453
442
 
454
443
  Rake::Task[:spec_clean_symlinks].invoke
455
444
 
456
- if File.zero?('spec/fixtures/manifests/site.pp')
457
- FileUtils.rm_f('spec/fixtures/manifests/site.pp')
458
- end
445
+ FileUtils.rm_f('spec/fixtures/manifests/site.pp') if File.empty?('spec/fixtures/manifests/site.pp')
459
446
  end
460
447
 
461
448
  desc 'Clean up any fixture symlinks'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PuppetlabsSpecHelper
4
- VERSION = '5.0.3'
4
+ VERSION = '6.0.0'
5
5
  end
@@ -9,6 +9,6 @@ RSpec.describe 'rake' do
9
9
  Open3.capture2e('rake', '--rakefile', 'spec/acceptance/fixtures/Rakefile', '-T')
10
10
  end
11
11
 
12
- it { expect(output[0]).to match %r{spec_prep} }
12
+ it { expect(output[0]).to match(/spec_prep/) }
13
13
  it { expect(output[1]).to be_success }
14
14
  end
data/spec/spec_helper.rb CHANGED
@@ -8,7 +8,7 @@ if ENV['COVERAGE'] == 'yes'
8
8
  SimpleCov.formatters = [
9
9
  SimpleCov::Formatter::HTMLFormatter,
10
10
  SimpleCov::Formatter::Console,
11
- SimpleCov::Formatter::Codecov,
11
+ SimpleCov::Formatter::Codecov
12
12
  ]
13
13
  SimpleCov.start do
14
14
  track_files 'lib/**/*.rb'
@@ -40,7 +40,7 @@ RSpec.shared_context 'with a rake task', type: :task do
40
40
 
41
41
  include FakeFS::SpecHelpers
42
42
 
43
- let(:task_name) { self.class.top_level_description.sub(%r{\Arake }, '') }
43
+ let(:task_name) { self.class.top_level_description.delete_prefix('rake ') }
44
44
  end
45
45
 
46
46
  # configure RSpec after including all the code
@@ -3,7 +3,7 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe 'rake check:symlinks', type: :task do
6
- before(:each) do
6
+ before do
7
7
  test_files.each do |f|
8
8
  FileUtils.mkdir_p(File.dirname(f))
9
9
  FileUtils.touch(f)
@@ -31,7 +31,7 @@ describe 'rake check:symlinks', type: :task do
31
31
  let(:test_files) do
32
32
  [
33
33
  File.join(Dir.pwd, 'files', 'a_file.pp'),
34
- File.join(Dir.pwd, 'files', 'another_file.pp'),
34
+ File.join(Dir.pwd, 'files', 'another_file.pp')
35
35
  ]
36
36
  end
37
37
 
@@ -43,19 +43,19 @@ describe 'rake check:symlinks', type: :task do
43
43
  context 'when there is a symlink present' do
44
44
  let(:test_files) do
45
45
  [
46
- File.join(Dir.pwd, 'files', 'a_file.pp'),
46
+ File.join(Dir.pwd, 'files', 'a_file.pp')
47
47
  ]
48
48
  end
49
49
 
50
50
  let(:symlinks) do
51
51
  {
52
- File.join(Dir.pwd, 'files', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp'),
52
+ File.join(Dir.pwd, 'files', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp')
53
53
  }
54
54
  end
55
55
 
56
56
  it 'raises an error' do
57
57
  expect { task.execute }
58
- .to raise_error(%r{symlink\(s\) exist}i)
58
+ .to raise_error(/symlink\(s\) exist/i)
59
59
  .and output(a_string_including(expected_output)).to_stdout
60
60
  end
61
61
  end
@@ -63,13 +63,13 @@ describe 'rake check:symlinks', type: :task do
63
63
  context 'when there are symlinks under .git/' do
64
64
  let(:test_files) do
65
65
  [
66
- File.join(Dir.pwd, 'files', 'a_file.pp'),
66
+ File.join(Dir.pwd, 'files', 'a_file.pp')
67
67
  ]
68
68
  end
69
69
 
70
70
  let(:symlinks) do
71
71
  {
72
- File.join(Dir.pwd, '.git', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp'),
72
+ File.join(Dir.pwd, '.git', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp')
73
73
  }
74
74
  end
75
75
 
@@ -81,13 +81,13 @@ describe 'rake check:symlinks', type: :task do
81
81
  context 'when there are symlinks under .bundle/' do
82
82
  let(:test_files) do
83
83
  [
84
- File.join(Dir.pwd, 'files', 'a_file.pp'),
84
+ File.join(Dir.pwd, 'files', 'a_file.pp')
85
85
  ]
86
86
  end
87
87
 
88
88
  let(:symlinks) do
89
89
  {
90
- File.join(Dir.pwd, '.bundle', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp'),
90
+ File.join(Dir.pwd, '.bundle', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp')
91
91
  }
92
92
  end
93
93
 
@@ -99,13 +99,13 @@ describe 'rake check:symlinks', type: :task do
99
99
  context 'when there are symlinks under vendor/' do
100
100
  let(:test_files) do
101
101
  [
102
- File.join(Dir.pwd, 'files', 'a_file.pp'),
102
+ File.join(Dir.pwd, 'files', 'a_file.pp')
103
103
  ]
104
104
  end
105
105
 
106
106
  let(:symlinks) do
107
107
  {
108
- File.join(Dir.pwd, 'vendor', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp'),
108
+ File.join(Dir.pwd, 'vendor', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp')
109
109
  }
110
110
  end
111
111
 
@@ -115,19 +115,19 @@ describe 'rake check:symlinks', type: :task do
115
115
  end
116
116
 
117
117
  context 'when there are symlinks under a directory listed in .gitignore' do
118
- before(:each) do
118
+ before do
119
119
  File.write(File.join(Dir.pwd, '.gitignore'), "a_directory/\n")
120
120
  end
121
121
 
122
122
  let(:test_files) do
123
123
  [
124
- File.join(Dir.pwd, 'files', 'a_file.pp'),
124
+ File.join(Dir.pwd, 'files', 'a_file.pp')
125
125
  ]
126
126
  end
127
127
 
128
128
  let(:symlinks) do
129
129
  {
130
- File.join(Dir.pwd, 'a_directory', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp'),
130
+ File.join(Dir.pwd, 'a_directory', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp')
131
131
  }
132
132
  end
133
133
 
@@ -137,7 +137,7 @@ describe 'rake check:symlinks', type: :task do
137
137
  end
138
138
 
139
139
  context 'when there are symlinks under a directory listed in .pdkignore' do
140
- before(:each) do
140
+ before do
141
141
  File.open(File.join(Dir.pwd, '.pdkignore'), 'w') do |f|
142
142
  f.puts '/another_directory/'
143
143
  end
@@ -145,13 +145,13 @@ describe 'rake check:symlinks', type: :task do
145
145
 
146
146
  let(:test_files) do
147
147
  [
148
- File.join(Dir.pwd, 'files', 'a_file.pp'),
148
+ File.join(Dir.pwd, 'files', 'a_file.pp')
149
149
  ]
150
150
  end
151
151
 
152
152
  let(:symlinks) do
153
153
  {
154
- File.join(Dir.pwd, 'another_directory', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp'),
154
+ File.join(Dir.pwd, 'another_directory', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp')
155
155
  }
156
156
  end
157
157
 
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  describe 'rake check:test_file', type: :task do
6
6
  context 'when there are .pp files under tests/' do
7
- before(:each) do
7
+ before do
8
8
  test_files.each do |f|
9
9
  FileUtils.mkdir_p(File.dirname(f))
10
10
  FileUtils.touch(f)
@@ -14,7 +14,7 @@ describe 'rake check:test_file', type: :task do
14
14
  let(:test_files) do
15
15
  [
16
16
  File.join(Dir.pwd, 'tests', 'an_example.pp'),
17
- File.join(Dir.pwd, 'tests', 'deep', 'directory', 'structure', 'another_example.pp'),
17
+ File.join(Dir.pwd, 'tests', 'deep', 'directory', 'structure', 'another_example.pp')
18
18
  ]
19
19
  end
20
20
 
@@ -22,13 +22,13 @@ describe 'rake check:test_file', type: :task do
22
22
  expected_output = test_files.join("\n")
23
23
 
24
24
  expect { task.execute }
25
- .to raise_error(%r{pp files present in tests folder})
25
+ .to raise_error(/pp files present in tests folder/)
26
26
  .and output(a_string_including(expected_output)).to_stdout
27
27
  end
28
28
  end
29
29
 
30
30
  context 'when there are no .pp files under tests/' do
31
- before(:each) do
31
+ before do
32
32
  FileUtils.mkdir('tests')
33
33
  end
34
34
 
@@ -7,7 +7,7 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
7
7
  describe '.module_name' do
8
8
  subject(:module_name) { described_class.module_name }
9
9
 
10
- before(:each) do
10
+ before do
11
11
  allow(Dir).to receive(:pwd).and_return(File.join('path', 'to', 'my-awsome-module_from_pwd'))
12
12
  end
13
13
 
@@ -24,7 +24,7 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
24
24
  end
25
25
 
26
26
  context 'when metadata.json does not exist' do
27
- before(:each) do
27
+ before do
28
28
  allow(File).to receive(:file?).with('metadata.json').and_return(false)
29
29
  end
30
30
 
@@ -32,49 +32,49 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
32
32
  end
33
33
 
34
34
  context 'when metadata.json does exist' do
35
- before(:each) do
35
+ before do
36
36
  allow(File).to receive(:file?).with('metadata.json').and_return(true)
37
37
  end
38
38
 
39
- context 'but it is not readable' do
40
- before(:each) do
39
+ context 'when it is not readable' do
40
+ before do
41
41
  allow(File).to receive(:readable?).with('metadata.json').and_return(false)
42
42
  end
43
43
 
44
44
  it_behaves_like 'module name from working directory'
45
45
  end
46
46
 
47
- context 'and it is readable' do
48
- before(:each) do
47
+ context 'when it is readable' do
48
+ before do
49
49
  allow(File).to receive(:readable?).with('metadata.json').and_return(true)
50
50
  allow(File).to receive(:read).with('metadata.json').and_return(metadata_content)
51
51
  end
52
52
 
53
- context 'but it contains invalid JSON' do
53
+ context 'when it contains invalid JSON' do
54
54
  let(:metadata_content) { '{ "name": "my-awesome-module_from_metadata", }' }
55
55
 
56
56
  it_behaves_like 'module name from working directory'
57
57
  end
58
58
 
59
- context 'and it contains a name value' do
59
+ context 'when it contains a name value' do
60
60
  let(:metadata_content) { '{ "name": "my-awesome-module_from_metadata" }' }
61
61
 
62
62
  it_behaves_like 'module name from metadata'
63
63
  end
64
64
 
65
- context 'but it does not contain a name value' do
65
+ context 'when it does not contain a name value' do
66
66
  let(:metadata_content) { '{}' }
67
67
 
68
68
  it_behaves_like 'module name from working directory'
69
69
  end
70
70
 
71
- context 'but the name has a null value' do
71
+ context 'when the name has a null value' do
72
72
  let(:metadata_content) { '{ "name": null }' }
73
73
 
74
74
  it_behaves_like 'module name from working directory'
75
75
  end
76
76
 
77
- context 'but the name is blank' do
77
+ context 'when the name is blank' do
78
78
  let(:metadata_content) { '{ "name": "" }' }
79
79
 
80
80
  it_behaves_like 'module name from working directory'
@@ -86,7 +86,7 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
86
86
  describe '.fixtures' do
87
87
  subject(:helper) { described_class }
88
88
 
89
- before :each do
89
+ before do
90
90
  # Unstub the fixtures "helpers"
91
91
  PuppetlabsSpec::Fixtures.instance_methods.each do |m|
92
92
  PuppetlabsSpec::Fixtures.send(:undef_method, m)
@@ -118,7 +118,7 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
118
118
  it 'raises an error' do
119
119
  expect(File).to receive(:exist?).with('.fixtures.yml').and_return true
120
120
  expect(YAML).to receive(:load_file).with('.fixtures.yml').and_raise(Psych::SyntaxError.new('/file', '123', '0', '0', 'spec message', 'spec context'))
121
- expect { helper.fixtures('forge_modules') }.to raise_error(RuntimeError, %r{malformed YAML})
121
+ expect { helper.fixtures('forge_modules') }.to raise_error(RuntimeError, /malformed YAML/)
122
122
  end
123
123
  end
124
124
 
@@ -126,7 +126,7 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
126
126
  it 'raises an error' do
127
127
  allow(File).to receive(:exist?).with('.fixtures.yml').and_return true
128
128
  allow(YAML).to receive(:load_file).with('.fixtures.yml').and_return('some' => 'key')
129
- expect { helper.fixtures('forge_modules') }.to raise_error(RuntimeError, %r{No 'fixtures'})
129
+ expect { helper.fixtures('forge_modules') }.to raise_error(RuntimeError, /No 'fixtures'/)
130
130
  end
131
131
  end
132
132
 
@@ -141,7 +141,7 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
141
141
  'branch' => nil,
142
142
  'scm' => nil,
143
143
  'flags' => nil,
144
- 'subdir' => nil,
144
+ 'subdir' => nil
145
145
  },
146
146
  )
147
147
  end
@@ -159,18 +159,18 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
159
159
  'branch' => nil,
160
160
  'scm' => nil,
161
161
  'flags' => '--module_repository=https://myforge.example.com/',
162
- 'subdir' => nil,
162
+ 'subdir' => nil
163
163
  },
164
164
  )
165
165
  end
166
166
  end
167
167
 
168
168
  context 'when file specifies repository fixtures' do
169
- before(:each) do
169
+ before do
170
170
  allow(File).to receive(:exist?).with('.fixtures.yml').and_return true
171
171
  allow(YAML).to receive(:load_file).with('.fixtures.yml').and_return(
172
172
  'fixtures' => {
173
- 'repositories' => { 'stdlib' => 'https://github.com/puppetlabs/puppetlabs-stdlib.git' },
173
+ 'repositories' => { 'stdlib' => 'https://github.com/puppetlabs/puppetlabs-stdlib.git' }
174
174
  },
175
175
  )
176
176
  end
@@ -183,14 +183,14 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
183
183
  'branch' => nil,
184
184
  'scm' => nil,
185
185
  'flags' => nil,
186
- 'subdir' => nil,
186
+ 'subdir' => nil
187
187
  },
188
188
  )
189
189
  end
190
190
  end
191
191
 
192
192
  context 'when file specifies repository fixtures with an invalid git ref' do
193
- before(:each) do
193
+ before do
194
194
  allow(File).to receive(:exist?).with('.fixtures.yml').and_return true
195
195
  allow(YAML).to receive(:load_file).with('.fixtures.yml').and_return(
196
196
  'fixtures' => {
@@ -198,9 +198,9 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
198
198
  'stdlib' => {
199
199
  'scm' => 'git',
200
200
  'repo' => 'https://github.com/puppetlabs/puppetlabs-stdlib.git',
201
- 'ref' => 'this/is/a/branch',
202
- },
203
- },
201
+ 'ref' => 'this/is/a/branch'
202
+ }
203
+ }
204
204
  },
205
205
  )
206
206
  end
@@ -222,9 +222,9 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
222
222
  'forge_modules' => {
223
223
  'stdlib' => {
224
224
  'repo' => 'puppetlabs-stdlib',
225
- 'puppet_version' => Puppet::PUPPETVERSION,
226
- },
227
- },
225
+ 'puppet_version' => Puppet::PUPPETVERSION
226
+ }
227
+ }
228
228
  },
229
229
  )
230
230
  expect(helper.fixtures('forge_modules')).to include('puppetlabs-stdlib')
@@ -236,9 +236,9 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
236
236
  'forge_modules' => {
237
237
  'stdlib' => {
238
238
  'repo' => 'puppetlabs-stdlib',
239
- 'puppet_version' => '>= 999.9.9',
240
- },
241
- },
239
+ 'puppet_version' => '>= 999.9.9'
240
+ }
241
+ }
242
242
  },
243
243
  )
244
244
  expect(helper.fixtures('forge_modules')).to eq({})
@@ -250,9 +250,9 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
250
250
  'forge_modules' => {
251
251
  'stdlib' => {
252
252
  'repo' => 'puppetlabs-stdlib',
253
- 'puppet_version' => Puppet::PUPPETVERSION,
254
- },
255
- },
253
+ 'puppet_version' => Puppet::PUPPETVERSION
254
+ }
255
+ }
256
256
  },
257
257
  )
258
258
  expect(helper.fixtures('forge_modules')).to include('puppetlabs-stdlib')
data/spec/watchr.rb CHANGED
@@ -10,8 +10,8 @@ def growl(message)
10
10
  growlnotify = `which growlnotify`.chomp
11
11
  title = 'Watchr Test Results'
12
12
  image = case message
13
- when %r{(\d+)\s+?(failure|error)}i
14
- (Regexp.last_match(1).to_i == 0) ? '~/.watchr_images/passed.png' : '~/.watchr_images/failed.png'
13
+ when /(\d+)\s+?(failure|error)/i
14
+ Regexp.last_match(1).to_i == 0 ? '~/.watchr_images/passed.png' : '~/.watchr_images/failed.png'
15
15
  else
16
16
  '~/.watchr_images/unknown.png'
17
17
  end
@@ -35,9 +35,7 @@ def run_spec_test(file)
35
35
  end
36
36
 
37
37
  def filter_rspec(data)
38
- data.split("\n").select { |l|
39
- l =~ %r{^(\d+)\s+exampl\w+.*?(\d+).*?failur\w+.*?(\d+).*?pending}
40
- }.join("\n")
38
+ data.split("\n").grep(/^(\d+)\s+exampl\w+.*?(\d+).*?failur\w+.*?(\d+).*?pending/).join("\n")
41
39
  end
42
40
 
43
41
  def run_all_tests