puppetlabs_spec_helper 7.4.0 → 9.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 +4 -4
- data/.rubocop.yml +10 -0
- data/README.md +11 -0
- data/lib/puppetlabs_spec_helper/rake_tasks.rb +11 -39
- data/lib/puppetlabs_spec_helper/tasks/fixtures.rb +3 -0
- data/lib/puppetlabs_spec_helper/version.rb +1 -1
- data/spec/unit/puppetlabs_spec_helper/puppetlabs_spec/puppet_internals_spec.rb +3 -3
- data/spec/unit/puppetlabs_spec_helper/tasks/fixture_helpers_spec.rb +23 -0
- metadata +28 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c4cd4445a342012f408a122df72e4cc1b1fd9ea91ed4d10c438e56374313bc7f
|
|
4
|
+
data.tar.gz: 3ca527e89669a54feb5e31b8295d0e7360332be23b700d1f1ee8c2e2d60846af
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d4ff8c4c842191dcece38c2b846e6ac1601ebfd3156839b9b5eacd38acc5a28eef889c78577f5feee70d040301706362d112c4a7de5f04ea8af4180e3ee716ff
|
|
7
|
+
data.tar.gz: 656a6365b0074ba0dfca155399f6aad0e5012dd1d3c7740928fd2a4edf5b48106dcbdcba2b1cba223e7d4f494cc8f979e7cea514c12dd4ee449362acd7ad3177
|
data/.rubocop.yml
CHANGED
|
@@ -4,6 +4,16 @@ inherit_from: .rubocop_todo.yml
|
|
|
4
4
|
inherit_gem:
|
|
5
5
|
voxpupuli-rubocop: rubocop.yml
|
|
6
6
|
|
|
7
|
+
AllCops:
|
|
8
|
+
Exclude:
|
|
9
|
+
- Gemfile
|
|
10
|
+
- Rakefile
|
|
11
|
+
- spec/fixtures/**/*
|
|
12
|
+
- vendor/bundle/**/*
|
|
13
|
+
NewCops: enable
|
|
14
|
+
SuggestExtensions: false
|
|
15
|
+
TargetRubyVersion: '3.2'
|
|
16
|
+
|
|
7
17
|
# Disabled
|
|
8
18
|
Style/ClassAndModuleChildren:
|
|
9
19
|
Enabled: false
|
data/README.md
CHANGED
|
@@ -216,6 +216,17 @@ When specifying the repo source of the fixture you have a few options as to whic
|
|
|
216
216
|
* `ref` and `branch` can be used together to get a specific revision on a specific branch
|
|
217
217
|
* Top level `defaults` option could be used to set global options
|
|
218
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
|
+
|
|
219
230
|
Fixtures Examples
|
|
220
231
|
-----------------
|
|
221
232
|
Basic fixtures that will symlink `spec/fixtures/modules/my_modules` to the
|
|
@@ -121,35 +121,8 @@ task :parallel_spec_standalone do |_t, args|
|
|
|
121
121
|
end
|
|
122
122
|
end
|
|
123
123
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
Rake::Task['build:pdk'].invoke
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
namespace :build do
|
|
130
|
-
desc 'Build Puppet module with PDK'
|
|
131
|
-
task :pdk do
|
|
132
|
-
require 'pdk/util'
|
|
133
|
-
require 'pdk/module/build'
|
|
134
|
-
|
|
135
|
-
path = PDK::Module::Build.invoke(force: true, 'target-dir': File.join(Dir.pwd, 'pkg'))
|
|
136
|
-
puts "Module built: #{path}"
|
|
137
|
-
rescue LoadError
|
|
138
|
-
_ = `pdk --version`
|
|
139
|
-
unless $CHILD_STATUS.success?
|
|
140
|
-
warn 'Unable to build module. Please install PDK or add the `pdk` gem to your Gemfile.'
|
|
141
|
-
abort
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
system('pdk build --force')
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
desc 'Clean a built module package'
|
|
149
|
-
task :clean do
|
|
150
|
-
FileUtils.rm_rf('pkg/')
|
|
151
|
-
end
|
|
152
|
-
|
|
124
|
+
# Ensure that any changes to lint here are reflected within the config_defaults.yml file inside the pdk-templates:
|
|
125
|
+
# - https://github.com/puppetlabs/pdk-templates/blob/d9e6478ff7730a8ce072ce0c1d36a9b79f05ba2c/config_defaults.yml#L69
|
|
153
126
|
require 'puppet-lint/tasks/puppet-lint'
|
|
154
127
|
# Must clear as it will not override the existing puppet-lint rake task since we require to import for
|
|
155
128
|
# the PuppetLint::RakeTask
|
|
@@ -170,8 +143,7 @@ puppet_lint_disable_checks = %w[
|
|
|
170
143
|
80chars
|
|
171
144
|
140chars
|
|
172
145
|
class_inherits_from_params_class
|
|
173
|
-
|
|
174
|
-
disable_autoloader_layout
|
|
146
|
+
autoloader_layout
|
|
175
147
|
documentation
|
|
176
148
|
single_quote_string_with_variables
|
|
177
149
|
]
|
|
@@ -186,14 +158,14 @@ PuppetLint::RakeTask.new(:lint_fix) do |config|
|
|
|
186
158
|
config.fix = true
|
|
187
159
|
end
|
|
188
160
|
|
|
189
|
-
require '
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
161
|
+
require 'puppetlabs-syntax/tasks/puppetlabs-syntax'
|
|
162
|
+
PuppetlabsSyntax.exclude_paths ||= []
|
|
163
|
+
PuppetlabsSyntax.exclude_paths << 'spec/fixtures/**/*'
|
|
164
|
+
PuppetlabsSyntax.exclude_paths << 'pkg/**/*'
|
|
165
|
+
PuppetlabsSyntax.exclude_paths << 'vendor/**/*'
|
|
166
|
+
PuppetlabsSyntax.exclude_paths << '.vendor/**/*'
|
|
167
|
+
PuppetlabsSyntax.check_hiera_keys = true
|
|
168
|
+
PuppetlabsSyntax.check_hiera_data = true
|
|
197
169
|
|
|
198
170
|
desc 'Check syntax of Ruby files and call :syntax and :metadata_lint'
|
|
199
171
|
task :validate do
|
|
@@ -379,6 +379,9 @@ module PuppetlabsSpecHelper
|
|
|
379
379
|
flags = " #{opts['flags']}" if opts['flags']
|
|
380
380
|
end
|
|
381
381
|
|
|
382
|
+
forge_token = ENV.fetch('FORGE_API_KEY', nil)
|
|
383
|
+
flags += " --forge_authorization \"Bearer #{forge_token}\"" if forge_token
|
|
384
|
+
|
|
382
385
|
return false if File.directory?(target) && (ref.empty? || opts['ref'] == module_version(target))
|
|
383
386
|
|
|
384
387
|
# The PMT cannot handle multi threaded runs due to cache directory collisons
|
|
@@ -32,7 +32,7 @@ describe PuppetlabsSpec::PuppetInternals do
|
|
|
32
32
|
let(:node) { described_class.node }
|
|
33
33
|
|
|
34
34
|
it 'can have a defined node' do
|
|
35
|
-
expect(described_class.compiler(node:
|
|
35
|
+
expect(described_class.compiler(node:).node).to be node
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
|
|
@@ -60,12 +60,12 @@ describe PuppetlabsSpec::PuppetInternals do
|
|
|
60
60
|
it 'accepts an injected scope' do
|
|
61
61
|
expect(Puppet::Parser::Functions).to receive(:function).with('my_func').and_return(true)
|
|
62
62
|
expect(scope).to receive(:method).with(:function_my_func).and_return(:fake_method)
|
|
63
|
-
expect(described_class.function_method('my_func', scope:
|
|
63
|
+
expect(described_class.function_method('my_func', scope:)).to eq(:fake_method)
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
it "returns nil if the function doesn't exist" do
|
|
67
67
|
expect(Puppet::Parser::Functions).to receive(:function).with('my_func').and_return(false)
|
|
68
|
-
expect(described_class.function_method('my_func', scope:
|
|
68
|
+
expect(described_class.function_method('my_func', scope:)).to be_nil
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
71
|
end
|
|
@@ -165,6 +165,29 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
|
|
|
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
|
metadata
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: puppetlabs_spec_helper
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 9.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Puppet, Inc.
|
|
8
8
|
- Community Contributors
|
|
9
|
-
autorequire:
|
|
9
|
+
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2026-08-20 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: mocha
|
|
@@ -52,53 +52,59 @@ dependencies:
|
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
53
|
version: '3'
|
|
54
54
|
- !ruby/object:Gem::Dependency
|
|
55
|
-
name:
|
|
55
|
+
name: puppetlabs-syntax
|
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
|
57
57
|
requirements:
|
|
58
58
|
- - "~>"
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: '
|
|
60
|
+
version: '7.2'
|
|
61
|
+
- - ">="
|
|
62
|
+
- !ruby/object:Gem::Version
|
|
63
|
+
version: 7.2.1
|
|
61
64
|
type: :runtime
|
|
62
65
|
prerelease: false
|
|
63
66
|
version_requirements: !ruby/object:Gem::Requirement
|
|
64
67
|
requirements:
|
|
65
68
|
- - "~>"
|
|
66
69
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: '
|
|
70
|
+
version: '7.2'
|
|
71
|
+
- - ">="
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
version: 7.2.1
|
|
68
74
|
- !ruby/object:Gem::Dependency
|
|
69
|
-
name: puppet-
|
|
75
|
+
name: puppet-lint
|
|
70
76
|
requirement: !ruby/object:Gem::Requirement
|
|
71
77
|
requirements:
|
|
72
78
|
- - "~>"
|
|
73
79
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: '
|
|
75
|
-
- - ">="
|
|
76
|
-
- !ruby/object:Gem::Version
|
|
77
|
-
version: 4.1.1
|
|
80
|
+
version: '5.0'
|
|
78
81
|
type: :runtime
|
|
79
82
|
prerelease: false
|
|
80
83
|
version_requirements: !ruby/object:Gem::Requirement
|
|
81
84
|
requirements:
|
|
82
85
|
- - "~>"
|
|
83
86
|
- !ruby/object:Gem::Version
|
|
84
|
-
version: '
|
|
85
|
-
- - ">="
|
|
86
|
-
- !ruby/object:Gem::Version
|
|
87
|
-
version: 4.1.1
|
|
87
|
+
version: '5.0'
|
|
88
88
|
- !ruby/object:Gem::Dependency
|
|
89
89
|
name: rspec-github
|
|
90
90
|
requirement: !ruby/object:Gem::Requirement
|
|
91
91
|
requirements:
|
|
92
|
-
- - "
|
|
92
|
+
- - ">="
|
|
93
93
|
- !ruby/object:Gem::Version
|
|
94
94
|
version: '2.0'
|
|
95
|
+
- - "<"
|
|
96
|
+
- !ruby/object:Gem::Version
|
|
97
|
+
version: '4'
|
|
95
98
|
type: :runtime
|
|
96
99
|
prerelease: false
|
|
97
100
|
version_requirements: !ruby/object:Gem::Requirement
|
|
98
101
|
requirements:
|
|
99
|
-
- - "
|
|
102
|
+
- - ">="
|
|
100
103
|
- !ruby/object:Gem::Version
|
|
101
104
|
version: '2.0'
|
|
105
|
+
- - "<"
|
|
106
|
+
- !ruby/object:Gem::Version
|
|
107
|
+
version: '4'
|
|
102
108
|
- !ruby/object:Gem::Dependency
|
|
103
109
|
name: rspec-puppet
|
|
104
110
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -161,7 +167,7 @@ homepage: http://github.com/puppetlabs/puppetlabs_spec_helper
|
|
|
161
167
|
licenses:
|
|
162
168
|
- Apache-2.0
|
|
163
169
|
metadata: {}
|
|
164
|
-
post_install_message:
|
|
170
|
+
post_install_message:
|
|
165
171
|
rdoc_options: []
|
|
166
172
|
require_paths:
|
|
167
173
|
- lib
|
|
@@ -169,16 +175,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
169
175
|
requirements:
|
|
170
176
|
- - ">="
|
|
171
177
|
- !ruby/object:Gem::Version
|
|
172
|
-
version: '2
|
|
178
|
+
version: '3.2'
|
|
173
179
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
180
|
requirements:
|
|
175
181
|
- - ">="
|
|
176
182
|
- !ruby/object:Gem::Version
|
|
177
183
|
version: '0'
|
|
178
184
|
requirements:
|
|
179
|
-
- puppet, >=
|
|
180
|
-
rubygems_version: 3.
|
|
181
|
-
signing_key:
|
|
185
|
+
- puppet, >= 8.0.0
|
|
186
|
+
rubygems_version: 3.4.19
|
|
187
|
+
signing_key:
|
|
182
188
|
specification_version: 4
|
|
183
189
|
summary: Standard tasks and configuration for module spec tests.
|
|
184
190
|
test_files: []
|