puppetlabs_spec_helper 6.0.1 → 8.0.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9697b23b7652cc4dd9158675666a7f64ea3a902a4ec8367977712b9549e94951
4
- data.tar.gz: e1913dfc25f36d2067d4f9003810e5d0602a105b2442aaca1bba8a09dff484bb
3
+ metadata.gz: f6e4f387a2e5ca2ffdaf54834dba59bddbc793d099a32844e406d6bcf1906345
4
+ data.tar.gz: a5d37de14da8a64547e4dd3a40a649b0eac66d7c73d7d2aff561dafc569c3299
5
5
  SHA512:
6
- metadata.gz: e3ee3dbfac1577f1933f00e9b2cb6ac5fb2b4162054b9e9dcedd5921c7cbdcd279dce6294db6ec9cf29919c572ab0087ff62b3175ad1b3ddb24c8d261553587b
7
- data.tar.gz: a0c034d5006429965a0a86a96de2011f708f9ce32893d2518dc6e062c73644560d6651f071c58a7c3d20c91e8013af46c45f14ea1cec7d61ff77beb52f05a0d3
6
+ metadata.gz: 0c5d1c7bc0f185b696570c75bccab95349681e09bc213e91f5ffeb855d462a4e98c30cc3049ccb44cb083936438ccc386bcee6096a92f2ff8e8eb48c1fc8478e
7
+ data.tar.gz: 7da07d5ea2f8c277944bb803765fe2a39695c38ee3342bf0da34fdefce301e20edce6d9a201337db7cbbb14536ac2f9894cb50925f439a6214f9aa1a35669b97
data/.rubocop.yml CHANGED
@@ -1,19 +1,12 @@
1
+ ---
1
2
  inherit_from: .rubocop_todo.yml
2
3
 
3
- require:
4
- - rubocop-performance
5
- - rubocop-rspec
6
-
7
- AllCops:
8
- Exclude:
9
- - Gemfile
10
- - Rakefile
11
- - spec/fixtures/**/*
12
- - vendor/bundle/**/*
13
- NewCops: enable
14
- SuggestExtensions: false
15
- TargetRubyVersion: '2.7'
4
+ inherit_gem:
5
+ voxpupuli-rubocop: rubocop.yml
16
6
 
17
7
  # Disabled
18
8
  Style/ClassAndModuleChildren:
19
9
  Enabled: false
10
+
11
+ Layout/LineLength:
12
+ Max: 200
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  Puppet Labs Spec Helper
2
2
  =======================
3
3
 
4
+ [![Code Owners](https://img.shields.io/badge/owners-DevX--team-blue)](https://github.com/puppetlabs/puppetlabs_spec_helper/blob/main/CODEOWNERS)
5
+ ![ci](https://github.com/puppetlabs/puppetlabs_spec_helper/actions/workflows/ci.yml/badge.svg)
6
+ ![GitHub release (latest by date)](https://img.shields.io/github/v/release/puppetlabs/puppetlabs_spec_helper)
7
+
4
8
  The Short Version
5
9
  -----------------
6
10
 
@@ -212,6 +216,17 @@ When specifying the repo source of the fixture you have a few options as to whic
212
216
  * `ref` and `branch` can be used together to get a specific revision on a specific branch
213
217
  * Top level `defaults` option could be used to set global options
214
218
 
219
+ Using Forge Authorization
220
+ -----------------
221
+
222
+ In order to perform forge operations which require authorization, such as installing premium modules, you can export your forge api key as an environment variable in your terminal.
223
+
224
+ ```bash
225
+ FORGE_API_KEY='your_api_key'
226
+ ```
227
+
228
+ puppetlabs_spec_helper will then automatically append this key to all `puppet module install` requests when running `rake spec_prep`.
229
+
215
230
  Fixtures Examples
216
231
  -----------------
217
232
  Basic fixtures that will symlink `spec/fixtures/modules/my_modules` to the
@@ -230,8 +245,8 @@ Add `firewall` and `stdlib` as required module fixtures:
230
245
  ```yaml
231
246
  fixtures:
232
247
  repositories:
233
- firewall: "git://github.com/puppetlabs/puppetlabs-firewall"
234
- stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib"
248
+ firewall: "https://github.com/puppetlabs/puppetlabs-firewall.git"
249
+ stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
235
250
  ```
236
251
 
237
252
  Put a supplementary repository at a different location
@@ -239,8 +254,8 @@ Put a supplementary repository at a different location
239
254
  ```yaml
240
255
  fixtures:
241
256
  repositories:
242
- firewall: "git://github.com/puppetlabs/puppetlabs-firewall"
243
- stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib"
257
+ firewall: "https://github.com/puppetlabs/puppetlabs-firewall.git"
258
+ stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
244
259
  control_repo:
245
260
  repo: "https://github.com/puppetlabs/control-repo"
246
261
  target: "spec/fixtures/control_repos"
@@ -251,9 +266,9 @@ Specify that the git tag `2.4.2` of `stdlib` should be checked out:
251
266
  ```yaml
252
267
  fixtures:
253
268
  repositories:
254
- firewall: "git://github.com/puppetlabs/puppetlabs-firewall"
269
+ firewall: "https://github.com/puppetlabs/puppetlabs-firewall.git"
255
270
  stdlib:
256
- repo: "git://github.com/puppetlabs/puppetlabs-stdlib"
271
+ repo: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
257
272
  ref: "2.6.0"
258
273
  ```
259
274
 
@@ -263,7 +278,7 @@ Only install the `yumrepo_core` module when testing against Puppet 7 or greater:
263
278
  fixtures:
264
279
  repositories:
265
280
  yumrepo_core:
266
- repo: "git://github.com/puppetlabs/puppetlabs-yumrepo_core"
281
+ repo: "https://github.com/puppetlabs/puppetlabs-yumrepo_core.git"
267
282
  puppet_version: ">= 6.0.0"
268
283
  ```
269
284
 
@@ -273,7 +288,7 @@ Move manifests and siblings to root directory when they are inside a `code` dire
273
288
  fixtures:
274
289
  repositories:
275
290
  stdlib:
276
- repo: "git://github.com/puppetlabs/puppetlabs-extradirectory"
291
+ repo: "https://github.com/puppetlabs/puppetlabs-extradirectory.git"
277
292
  subdir: "code"
278
293
  ```
279
294
 
@@ -299,7 +314,7 @@ fixtures:
299
314
  flags: "--module_repository https://my_repo.com"
300
315
  repositories:
301
316
  firewall:
302
- repo: "git://github.com/puppetlabs/puppetlabs-firewall"
317
+ repo: "https://github.com/puppetlabs/puppetlabs-firewall.git"
303
318
  ref: "2.6.0"
304
319
  flags: "--verbose"
305
320
  ```
@@ -317,7 +332,7 @@ fixtures:
317
332
  ref: "2.6.0"
318
333
  repositories:
319
334
  firewall:
320
- repo: "git://github.com/puppetlabs/puppetlabs-firewall"
335
+ repo: "https://github.com/puppetlabs/puppetlabs-firewall.git"
321
336
  ref: "2.6.0"
322
337
  ```
323
338
 
@@ -406,7 +421,7 @@ You can enable it, set the following environment variable:s
406
421
 
407
422
  ``SIMPLECOV=yes``
408
423
 
409
- Remember to add the simplecov-console and codecov gems to your `Gemfile`. If you run `spec:simplecov` on Travis-CI or any of the other supported CI services, reports gets automatically uploaded to https://codecov.io/ .
424
+ Remember to add the simplecov-console gem to your `Gemfile`. If you run `spec:simplecov` on Travis-CI or any of the other supported CI services, reports get generated which can then be uploaded to [codecov.io](https://codecov.io) with the recommended [codecov uploader](https://docs.codecov.com/docs/codecov-uploader).
410
425
 
411
426
  Some Notes for Windows Users
412
427
  ============================
@@ -481,3 +496,7 @@ Rationale
481
496
  * mocha is an additional dependency to carry.
482
497
 
483
498
  EOF
499
+
500
+ ## License
501
+
502
+ This codebase is licensed under Apache 2.0. However, the open source dependencies included in this codebase might be subject to other software licenses such as AGPL, GPL2.0, and MIT.
@@ -20,35 +20,42 @@ env_module_path = ENV.fetch('MODULEPATH', nil)
20
20
  module_path = File.join(fixture_path, 'modules')
21
21
 
22
22
  module_path = [module_path, env_module_path].join(File::PATH_SEPARATOR) if env_module_path
23
+
23
24
  if ENV['SIMPLECOV'] == 'yes'
24
25
  begin
25
26
  require 'simplecov'
26
27
  require 'simplecov-console'
28
+ rescue LoadError
29
+ raise 'Add the simplecov and simplecov-console gems to Gemfile to enable this task'
30
+ end
31
+
32
+ SimpleCov.formatters = [
33
+ SimpleCov::Formatter::HTMLFormatter,
34
+ SimpleCov::Formatter::Console,
35
+ ]
36
+
37
+ begin
27
38
  require 'codecov'
39
+ SimpleCov.formatters << SimpleCov::Formatter::Codecov
40
+ rescue LoadError
41
+ # continue without codecov, we could warn here but we want to avoid its use if possible
42
+ end
43
+
44
+ SimpleCov.start do
45
+ track_files 'lib/**/*.rb'
46
+ add_filter '/spec'
28
47
 
29
- SimpleCov.formatters = [
30
- SimpleCov::Formatter::HTMLFormatter,
31
- SimpleCov::Formatter::Console,
32
- SimpleCov::Formatter::Codecov
33
- ]
34
- SimpleCov.start do
35
- track_files 'lib/**/*.rb'
36
- add_filter '/spec'
37
-
38
- # do not track vendored files
39
- add_filter '/vendor'
40
- add_filter '/.vendor'
41
-
42
- # do not track gitignored files
43
- # this adds about 4 seconds to the coverage check
44
- # this could definitely be optimized
45
- add_filter do |f|
46
- # system returns true if exit status is 0, which with git-check-ignore means file is ignored
47
- system("git check-ignore --quiet #{f.filename}")
48
- end
48
+ # do not track vendored files
49
+ add_filter '/vendor'
50
+ add_filter '/.vendor'
51
+
52
+ # do not track gitignored files
53
+ # this adds about 4 seconds to the coverage check
54
+ # this could definitely be optimized
55
+ add_filter do |f|
56
+ # system returns true if exit status is 0, which with git-check-ignore means file is ignored
57
+ system("git check-ignore --quiet #{f.filename}")
49
58
  end
50
- rescue LoadError
51
- raise 'Add the simplecov, simplecov-console, codecov gems to Gemfile to enable this task'
52
59
  end
53
60
  end
54
61
 
@@ -58,7 +65,7 @@ components = module_path.split(File::PATH_SEPARATOR).map do |dir|
58
65
 
59
66
  Dir.entries(dir).grep_v(/^\./).map { |f| File.join(dir, f, 'spec', 'lib') }
60
67
  end
61
- components.flatten.each do |d|
68
+ components.compact.flatten.each do |d|
62
69
  $LOAD_PATH << d if FileTest.directory?(d) && !$LOAD_PATH.include?(d)
63
70
  end
64
71
 
@@ -67,7 +74,6 @@ RSpec.configure do |c|
67
74
 
68
75
  c.environmentpath = spec_path
69
76
  c.module_path = module_path
70
- c.manifest_dir = File.join(fixture_path, 'manifests')
71
77
 
72
78
  # https://github.com/puppetlabs/rspec-puppet#strict_variables
73
79
  c.strict_variables = ENV['STRICT_VARIABLES'] != 'no'
@@ -39,7 +39,7 @@ module PuppetlabsSpec
39
39
  # exposed hack.
40
40
  return nil unless Puppet::Parser::Functions.function(name)
41
41
 
42
- scope.method("function_#{name}".to_sym)
42
+ scope.method(:"function_#{name}")
43
43
  end
44
44
  module_function :function_method
45
45
  end
@@ -111,8 +111,9 @@ task :parallel_spec_standalone do |_t, args|
111
111
  warn 'No files for parallel_spec to run against'
112
112
  else
113
113
 
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?
114
+ args = ['--type', 'rspec']
115
+ additional_options = ['--format', 'progress'] + ENV['CI_SPEC_OPTIONS'].to_s.strip.split
116
+ args.push('--').concat(additional_options).push('--')
116
117
  args.concat(Rake::FileList[pattern].to_a)
117
118
 
118
119
  ParallelTests::CLI.new.run(args)
@@ -120,35 +121,6 @@ task :parallel_spec_standalone do |_t, args|
120
121
  end
121
122
  end
122
123
 
123
- desc 'Build puppet module package'
124
- task :build do
125
- Rake::Task['build:pdk'].invoke
126
- end
127
-
128
- namespace :build do
129
- desc 'Build Puppet module with PDK'
130
- task :pdk do
131
- require 'pdk/util'
132
- require 'pdk/module/build'
133
-
134
- path = PDK::Module::Build.invoke(force: true, 'target-dir': File.join(Dir.pwd, 'pkg'))
135
- puts "Module built: #{path}"
136
- rescue LoadError
137
- _ = `pdk --version`
138
- unless $CHILD_STATUS.success?
139
- warn 'Unable to build module. Please install PDK or add the `pdk` gem to your Gemfile.'
140
- abort
141
- end
142
-
143
- system('pdk build --force')
144
- end
145
- end
146
-
147
- desc 'Clean a built module package'
148
- task :clean do
149
- FileUtils.rm_rf('pkg/')
150
- end
151
-
152
124
  require 'puppet-lint/tasks/puppet-lint'
153
125
  # Must clear as it will not override the existing puppet-lint rake task since we require to import for
154
126
  # the PuppetLint::RakeTask
@@ -169,14 +141,13 @@ puppet_lint_disable_checks = %w[
169
141
  80chars
170
142
  140chars
171
143
  class_inherits_from_params_class
172
- class_parameter_defaults
173
144
  disable_autoloader_layout
174
145
  documentation
175
146
  single_quote_string_with_variables
176
147
  ]
177
148
 
178
149
  puppet_lint_disable_checks.each do |check|
179
- PuppetLint.configuration.send("disable_#{check}")
150
+ PuppetLint.configuration.send(:"disable_#{check}")
180
151
  end
181
152
  PuppetLint::RakeTask.new(:lint)
182
153
 
@@ -191,7 +162,8 @@ PuppetSyntax.exclude_paths << 'spec/fixtures/**/*'
191
162
  PuppetSyntax.exclude_paths << 'pkg/**/*'
192
163
  PuppetSyntax.exclude_paths << 'vendor/**/*'
193
164
  PuppetSyntax.exclude_paths << '.vendor/**/*'
194
- PuppetSyntax.exclude_paths << 'plans/**/*'
165
+ PuppetSyntax.check_hiera_keys = true
166
+ PuppetSyntax.check_hiera_data = true
195
167
 
196
168
  desc 'Check syntax of Ruby files and call :syntax and :metadata_lint'
197
169
  task :validate do
@@ -379,16 +351,16 @@ def create_gch_task(changelog_user = nil, changelog_project = nil, changelog_sin
379
351
  config.configure_sections = {
380
352
  'Changed' => {
381
353
  'prefix' => '### Changed',
382
- 'labels' => ['backwards-incompatible']
354
+ 'labels' => ['backwards-incompatible'],
383
355
  },
384
356
  'Added' => {
385
357
  'prefix' => '### Added',
386
- 'labels' => %w[feature enhancement]
358
+ 'labels' => %w[feature enhancement],
387
359
  },
388
360
  'Fixed' => {
389
361
  'prefix' => '### Fixed',
390
- 'labels' => ['bugfix']
391
- }
362
+ 'labels' => ['bugfix'],
363
+ },
392
364
  }
393
365
  end
394
366
  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)
@@ -106,8 +106,7 @@ module PuppetlabsSpecHelper
106
106
  end
107
107
 
108
108
  fixtures = fixtures['fixtures']
109
-
110
- fixtures['symlinks'] = auto_symlink if fixtures['symlinks'].nil?
109
+ fixtures['symlinks'] = (fixtures['symlinks'].nil? || fixtures['symlinks'].empty?) ? auto_symlink : auto_symlink.merge!(fixtures['symlinks'])
111
110
 
112
111
  result = {}
113
112
  if fixtures.include?(category) && !fixtures[category].nil?
@@ -151,7 +150,7 @@ module PuppetlabsSpecHelper
151
150
  return hash unless hash['scm'] == 'git'
152
151
 
153
152
  # Forward slashes in the ref aren't allowed. And is probably a branch name.
154
- raise ArgumentError, "The ref for #{hash['target']} is invalid (Contains a forward slash). If this is a branch name, please use the 'branch' setting instead." if hash['ref'].include?('/')
153
+ raise ArgumentError, "The ref for #{hash['target']} is invalid (Contains a forward slash). If this is a branch name, please use the 'branch' setting instead." if hash['ref']&.include?('/')
155
154
 
156
155
  hash
157
156
  end
@@ -318,7 +317,7 @@ module PuppetlabsSpecHelper
318
317
  end
319
318
  end
320
319
  # wait for all the threads to finish
321
- items.each { |_remote, opts| opts[:thread].join }
320
+ items.each_value { |opts| opts[:thread].join }
322
321
  end
323
322
 
324
323
  # @param target [String] - the target directory
@@ -380,6 +379,9 @@ module PuppetlabsSpecHelper
380
379
  flags = " #{opts['flags']}" if opts['flags']
381
380
  end
382
381
 
382
+ forge_token = ENV.fetch('FORGE_API_KEY', nil)
383
+ flags += " --forge_authorization \"Bearer #{forge_token}\"" if forge_token
384
+
383
385
  return false if File.directory?(target) && (ref.empty? || opts['ref'] == module_version(target))
384
386
 
385
387
  # The PMT cannot handle multi threaded runs due to cache directory collisons
@@ -428,12 +430,12 @@ end
428
430
 
429
431
  desc 'Clean up the fixtures directory'
430
432
  task :spec_clean do
431
- repositories.each do |_remote, opts|
433
+ repositories.each_value do |opts|
432
434
  target = opts['target']
433
435
  FileUtils.rm_rf(target)
434
436
  end
435
437
 
436
- forge_modules.each do |_remote, opts|
438
+ forge_modules.each_value do |opts|
437
439
  target = opts['target']
438
440
  FileUtils.rm_rf(target)
439
441
  end
@@ -447,7 +449,7 @@ end
447
449
 
448
450
  desc 'Clean up any fixture symlinks'
449
451
  task :spec_clean_symlinks do
450
- fixtures('symlinks').each do |_source, opts|
452
+ fixtures('symlinks').each_value do |opts|
451
453
  target = opts['target']
452
454
  FileUtils.rm_f(target)
453
455
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PuppetlabsSpecHelper
4
- VERSION = '6.0.1'
4
+ VERSION = '8.0.0'
5
5
  end
data/spec/spec_helper.rb CHANGED
@@ -1,15 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  if ENV['COVERAGE'] == 'yes'
4
- require 'simplecov'
5
- require 'simplecov-console'
6
- require 'codecov'
4
+ begin
5
+ require 'simplecov'
6
+ require 'simplecov-console'
7
+ rescue LoadError
8
+ raise 'Add the simplecov and simplecov-console gems to Gemfile to enable this task'
9
+ end
7
10
 
8
11
  SimpleCov.formatters = [
9
12
  SimpleCov::Formatter::HTMLFormatter,
10
13
  SimpleCov::Formatter::Console,
11
- SimpleCov::Formatter::Codecov
12
14
  ]
15
+
13
16
  SimpleCov.start do
14
17
  track_files 'lib/**/*.rb'
15
18
 
@@ -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,13 +43,13 @@ 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
 
@@ -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
 
@@ -121,13 +121,13 @@ describe 'rake check:symlinks', type: :task do
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
 
@@ -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
 
@@ -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
 
@@ -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,41 @@ 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
+ context 'when forge_api_key env variable is set' do
169
+ before do
170
+ # required to prevent unwanted output on stub of $CHILD_STATUS
171
+ RSpec::Mocks.configuration.allow_message_expectations_on_nil = true
172
+ end
173
+
174
+ after do
175
+ RSpec::Mocks.configuration.allow_message_expectations_on_nil = false
176
+ end
177
+
178
+ it 'correctly sets --forge_authorization' do
179
+ allow(ENV).to receive(:fetch).with('FORGE_API_KEY', nil).and_return('myforgeapikey')
180
+ # Mock the system call to prevent actual execution
181
+ allow_any_instance_of(Kernel).to receive(:system) do |command| # rubocop:disable RSpec/AnyInstance
182
+ expect(command).to include('--forge_authorization "Bearer myforgeapikey"')
183
+ # Simulate setting $CHILD_STATUS to a successful status
184
+ allow($CHILD_STATUS).to receive(:success?).and_return(true)
185
+ true
186
+ end
187
+ helper.download_module('puppetlabs-stdlib', 'target' => 'spec/fixtures/modules/stdlib')
188
+ end
189
+ end
190
+
168
191
  context 'when file specifies repository fixtures' do
169
192
  before do
170
193
  allow(File).to receive(:exist?).with('.fixtures.yml').and_return true
171
194
  allow(YAML).to receive(:load_file).with('.fixtures.yml').and_return(
172
195
  'fixtures' => {
173
- 'repositories' => { 'stdlib' => 'https://github.com/puppetlabs/puppetlabs-stdlib.git' }
196
+ 'repositories' => { 'stdlib' => 'https://github.com/puppetlabs/puppetlabs-stdlib.git' },
174
197
  },
175
198
  )
176
199
  end
@@ -183,7 +206,7 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
183
206
  'branch' => nil,
184
207
  'scm' => nil,
185
208
  'flags' => nil,
186
- 'subdir' => nil
209
+ 'subdir' => nil,
187
210
  },
188
211
  )
189
212
  end
@@ -198,9 +221,9 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
198
221
  'stdlib' => {
199
222
  'scm' => 'git',
200
223
  'repo' => 'https://github.com/puppetlabs/puppetlabs-stdlib.git',
201
- 'ref' => 'this/is/a/branch'
202
- }
203
- }
224
+ 'ref' => 'this/is/a/branch',
225
+ },
226
+ },
204
227
  },
205
228
  )
206
229
  end
@@ -222,9 +245,9 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
222
245
  'forge_modules' => {
223
246
  'stdlib' => {
224
247
  'repo' => 'puppetlabs-stdlib',
225
- 'puppet_version' => Puppet::PUPPETVERSION
226
- }
227
- }
248
+ 'puppet_version' => Puppet::PUPPETVERSION,
249
+ },
250
+ },
228
251
  },
229
252
  )
230
253
  expect(helper.fixtures('forge_modules')).to include('puppetlabs-stdlib')
@@ -236,9 +259,9 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
236
259
  'forge_modules' => {
237
260
  'stdlib' => {
238
261
  'repo' => 'puppetlabs-stdlib',
239
- 'puppet_version' => '>= 999.9.9'
240
- }
241
- }
262
+ 'puppet_version' => '>= 999.9.9',
263
+ },
264
+ },
242
265
  },
243
266
  )
244
267
  expect(helper.fixtures('forge_modules')).to eq({})
@@ -250,9 +273,9 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
250
273
  'forge_modules' => {
251
274
  'stdlib' => {
252
275
  'repo' => 'puppetlabs-stdlib',
253
- 'puppet_version' => Puppet::PUPPETVERSION
254
- }
255
- }
276
+ 'puppet_version' => Puppet::PUPPETVERSION,
277
+ },
278
+ },
256
279
  },
257
280
  )
258
281
  expect(helper.fixtures('forge_modules')).to include('puppetlabs-stdlib')
data/spec/watchr.rb CHANGED
@@ -11,7 +11,7 @@ def growl(message)
11
11
  title = 'Watchr Test Results'
12
12
  image = case message
13
13
  when /(\d+)\s+?(failure|error)/i
14
- Regexp.last_match(1).to_i == 0 ? '~/.watchr_images/passed.png' : '~/.watchr_images/failed.png'
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppetlabs_spec_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.1
4
+ version: 8.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet, Inc.
@@ -9,22 +9,28 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-04-25 00:00:00.000000000 Z
12
+ date: 2024-09-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mocha
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '1.0'
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '3'
21
24
  type: :runtime
22
25
  prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
24
27
  requirements:
25
- - - "~>"
28
+ - - ">="
26
29
  - !ruby/object:Gem::Version
27
30
  version: '1.0'
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '3'
28
34
  - !ruby/object:Gem::Dependency
29
35
  name: pathspec
30
36
  requirement: !ruby/object:Gem::Requirement
@@ -34,7 +40,7 @@ dependencies:
34
40
  version: '0.2'
35
41
  - - "<"
36
42
  - !ruby/object:Gem::Version
37
- version: 2.0.0
43
+ version: '3'
38
44
  type: :runtime
39
45
  prerelease: false
40
46
  version_requirements: !ruby/object:Gem::Requirement
@@ -44,35 +50,41 @@ dependencies:
44
50
  version: '0.2'
45
51
  - - "<"
46
52
  - !ruby/object:Gem::Version
47
- version: 2.0.0
53
+ version: '3'
48
54
  - !ruby/object:Gem::Dependency
49
55
  name: puppet-lint
50
56
  requirement: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - ">="
58
+ - - "~>"
53
59
  - !ruby/object:Gem::Version
54
- version: 3.0.0
60
+ version: '4.0'
55
61
  type: :runtime
56
62
  prerelease: false
57
63
  version_requirements: !ruby/object:Gem::Requirement
58
64
  requirements:
59
- - - ">="
65
+ - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: 3.0.0
67
+ version: '4.0'
62
68
  - !ruby/object:Gem::Dependency
63
69
  name: puppet-syntax
64
70
  requirement: !ruby/object:Gem::Requirement
65
71
  requirements:
66
72
  - - "~>"
67
73
  - !ruby/object:Gem::Version
68
- version: '3.0'
74
+ version: '4.1'
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: 4.1.1
69
78
  type: :runtime
70
79
  prerelease: false
71
80
  version_requirements: !ruby/object:Gem::Requirement
72
81
  requirements:
73
82
  - - "~>"
74
83
  - !ruby/object:Gem::Version
75
- version: '3.0'
84
+ version: '4.1'
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: 4.1.1
76
88
  - !ruby/object:Gem::Dependency
77
89
  name: rspec-github
78
90
  requirement: !ruby/object:Gem::Requirement
@@ -91,16 +103,30 @@ dependencies:
91
103
  name: rspec-puppet
92
104
  requirement: !ruby/object:Gem::Requirement
93
105
  requirements:
94
- - - ">="
106
+ - - "~>"
95
107
  - !ruby/object:Gem::Version
96
- version: '2.0'
108
+ version: '5.0'
97
109
  type: :runtime
98
110
  prerelease: false
99
111
  version_requirements: !ruby/object:Gem::Requirement
100
112
  requirements:
101
- - - ">="
113
+ - - "~>"
102
114
  - !ruby/object:Gem::Version
103
- version: '2.0'
115
+ version: '5.0'
116
+ - !ruby/object:Gem::Dependency
117
+ name: voxpupuli-rubocop
118
+ requirement: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - "~>"
121
+ - !ruby/object:Gem::Version
122
+ version: 2.8.0
123
+ type: :development
124
+ prerelease: false
125
+ version_requirements: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: 2.8.0
104
130
  description: Contains rake tasks and a standard spec_helper for running spec tests
105
131
  on puppet modules.
106
132
  email: