rspec-puppet 4.0.2 → 5.0.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +28 -1
- data/LICENSE +20 -0
- data/README.md +66 -40
- data/bin/rspec-puppet-init +1 -1
- data/lib/rspec-puppet/adapters.rb +7 -11
- data/lib/rspec-puppet/consts.rb +6 -6
- data/lib/rspec-puppet/coverage.rb +3 -5
- data/lib/rspec-puppet/example/function_example_group.rb +7 -9
- data/lib/rspec-puppet/example/type_example_group.rb +1 -1
- data/lib/rspec-puppet/matchers/allow_value.rb +1 -1
- data/lib/rspec-puppet/matchers/count_generic.rb +3 -3
- data/lib/rspec-puppet/matchers/create_generic.rb +13 -29
- data/lib/rspec-puppet/matchers/dynamic_matchers.rb +5 -5
- data/lib/rspec-puppet/matchers/parameter_matcher.rb +2 -0
- data/lib/rspec-puppet/matchers/raise_error.rb +2 -2
- data/lib/rspec-puppet/matchers/run.rb +1 -1
- data/lib/rspec-puppet/monkey_patches/windows/taskschedulerconstants.rb +2 -2
- data/lib/rspec-puppet/monkey_patches.rb +4 -4
- data/lib/rspec-puppet/sensitive.rb +5 -0
- data/lib/rspec-puppet/setup.rb +1 -1
- data/lib/rspec-puppet/support.rb +17 -26
- data/lib/rspec-puppet/tasks/release_test.rb +1 -1
- data/lib/rspec-puppet/version.rb +1 -1
- metadata +20 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 90c80a0c8b7a303f9e8307598572f6501b91668b325b9ddf297a267ee24ef4d2
|
|
4
|
+
data.tar.gz: f73ec645dd29669a8749e8b8dd12e714109c4e613a4c94acb031524288052ff5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 378d47cb8c9a0c026185218f9925c08c804acf1dd3d417be41d44bc004045d433dcc1b21bc96d36ee16cbebb1508f7033a27aea34e85dc9a7e1e1c0ceb3084f2
|
|
7
|
+
data.tar.gz: 6a96f0c9a10fe84ba051defd74651c945036b5294aba6e0680a3cd1effc6a34981c8c9219c535607f404cefd1bc1d9a79d2a0d0117f481c8c93d678ce1f0dc94
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,27 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
|
|
6
6
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).
|
|
7
7
|
|
|
8
|
+
## [v5.0.1](https://github.com/puppetlabs/rspec-puppet/tree/v5.0.1) - 2026-09-03
|
|
9
|
+
|
|
10
|
+
[Full Changelog](https://github.com/puppetlabs/rspec-puppet/compare/v5.0.0...v5.0.1)
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- (CAT-2281) Remove puppet 7 infrastructure [#133](https://github.com/puppetlabs/rspec-puppet/pull/133) ([LukasAud](https://github.com/LukasAud))
|
|
15
|
+
|
|
16
|
+
## [v5.0.0](https://github.com/puppetlabs/rspec-puppet/tree/v5.0.0) - 2024-09-06
|
|
17
|
+
|
|
18
|
+
[Full Changelog](https://github.com/puppetlabs/rspec-puppet/compare/v4.0.2...v5.0.0)
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- Unwrap sensitive values in error messages [#42](https://github.com/puppetlabs/rspec-puppet/pull/42) ([smortex](https://github.com/smortex))
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- server_facts: Switch from legacy to structured facts [#127](https://github.com/puppetlabs/rspec-puppet/pull/127) ([bastelfreak](https://github.com/bastelfreak))
|
|
27
|
+
- (bug) - Add license file to built gem [#108](https://github.com/puppetlabs/rspec-puppet/pull/108) ([jordanbreen28](https://github.com/jordanbreen28))
|
|
28
|
+
|
|
8
29
|
## [v4.0.2](https://github.com/puppetlabs/rspec-puppet/tree/v4.0.2) - 2023-12-05
|
|
9
30
|
|
|
10
31
|
[Full Changelog](https://github.com/puppetlabs/rspec-puppet/compare/v4.0.1...v4.0.2)
|
|
@@ -27,6 +48,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
|
27
48
|
[Full Changelog](https://github.com/puppetlabs/rspec-puppet/compare/v3.0.0...v4.0.0)
|
|
28
49
|
|
|
29
50
|
### Changed
|
|
51
|
+
|
|
30
52
|
- (CAT-1226) - Remove Compatibility for Puppet 7.10 and below [#73](https://github.com/puppetlabs/rspec-puppet/pull/73) ([jordanbreen28](https://github.com/jordanbreen28))
|
|
31
53
|
- Drop RSpec 2 & Ruby 1 compatiblity [#67](https://github.com/puppetlabs/rspec-puppet/pull/67) ([ekohl](https://github.com/ekohl))
|
|
32
54
|
- Remove puppet applications support [#54](https://github.com/puppetlabs/rspec-puppet/pull/54) ([nabertrand](https://github.com/nabertrand))
|
|
@@ -44,6 +66,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
|
44
66
|
[Full Changelog](https://github.com/puppetlabs/rspec-puppet/compare/v2.12.0...v3.0.0.rc.1)
|
|
45
67
|
|
|
46
68
|
### Changed
|
|
69
|
+
|
|
47
70
|
- (CONT-808) Ruby 3 / Puppet 8 Support [#48](https://github.com/puppetlabs/rspec-puppet/pull/48) ([chelnak](https://github.com/chelnak))
|
|
48
71
|
|
|
49
72
|
### Added
|
|
@@ -97,7 +120,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
|
97
120
|
|
|
98
121
|
## [v2.8.0](https://github.com/puppetlabs/rspec-puppet/tree/v2.8.0) - 2020-11-05
|
|
99
122
|
|
|
100
|
-
[Full Changelog](https://github.com/puppetlabs/rspec-puppet/compare/v2.7.
|
|
123
|
+
[Full Changelog](https://github.com/puppetlabs/rspec-puppet/compare/v2.7.10...v2.8.0)
|
|
124
|
+
|
|
125
|
+
## [v2.7.10](https://github.com/puppetlabs/rspec-puppet/tree/v2.7.10) - 2020-07-15
|
|
126
|
+
|
|
127
|
+
[Full Changelog](https://github.com/puppetlabs/rspec-puppet/compare/v2.7.9...v2.7.10)
|
|
101
128
|
|
|
102
129
|
## [v2.7.9](https://github.com/puppetlabs/rspec-puppet/tree/v2.7.9) - 2020-07-14
|
|
103
130
|
|
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2011 Tim Sharpe
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
18
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
|
@@ -888,66 +888,92 @@ end
|
|
|
888
888
|
|
|
889
889
|
## Hiera integration
|
|
890
890
|
|
|
891
|
+
At some point, you might want to make use of Hiera to bring in custom parameters for your class tests. In this section, we will
|
|
892
|
+
provide you with basic guidance to setup Hiera implementation within rspec testing. For more information on Hiera, you should
|
|
893
|
+
check our official [documentation](https://www.puppet.com/docs/puppet/latest/hiera.html).
|
|
894
|
+
|
|
891
895
|
### Configuration
|
|
892
896
|
|
|
893
|
-
|
|
897
|
+
The first step is to create the general hiera configuration file. Since we want this to be exclusive for testing, we recommend creating
|
|
898
|
+
it inside your spec folder. Something along the lines of `spec/fixtures/hiera/hiera-rspec.yaml`. It should look something like this:
|
|
894
899
|
|
|
895
|
-
```
|
|
896
|
-
|
|
897
|
-
|
|
900
|
+
```yaml
|
|
901
|
+
---
|
|
902
|
+
version: 5
|
|
903
|
+
defaults: # Used for any hierarchy level that omits these keys.
|
|
904
|
+
datadir: data # This path is relative to hiera.yaml's directory.
|
|
905
|
+
data_hash: yaml_data # Use the built-in YAML backend.
|
|
906
|
+
|
|
907
|
+
hierarchy:
|
|
908
|
+
- name: 'rspec'
|
|
909
|
+
path: 'rspec-data.yaml'
|
|
898
910
|
```
|
|
899
911
|
|
|
900
|
-
|
|
912
|
+
It is often recommended to use dummy data during testing to avoid real values from being entangled. In order to create
|
|
913
|
+
these values, we will need a new file containing this data exclusively, normally existing within a subfolder called `data`, ending up with
|
|
914
|
+
`spec/fixtures/hiera/data/rspec-data.yaml`. Here is an example of its contents:
|
|
901
915
|
|
|
902
|
-
|
|
903
|
-
```ruby
|
|
916
|
+
```yaml
|
|
904
917
|
---
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
:
|
|
908
|
-
- test
|
|
909
|
-
:yaml:
|
|
910
|
-
:datadir: 'spec/fixtures/hiera'
|
|
918
|
+
# We will be using this data in later examples
|
|
919
|
+
message: 'Hello world!'
|
|
920
|
+
dummy:message2: 'foobar' # autoloaded parameter
|
|
911
921
|
```
|
|
912
922
|
|
|
913
|
-
spec
|
|
923
|
+
Finally, we make the target class spec file load the Hiera config, at which point we will be able to freely access it:
|
|
924
|
+
|
|
914
925
|
```ruby
|
|
915
|
-
|
|
916
|
-
ntpserver: ['ntp1.domain.com','ntpXX.domain.com']
|
|
917
|
-
user:
|
|
918
|
-
oneuser:
|
|
919
|
-
shell: '/bin/bash'
|
|
920
|
-
twouser:
|
|
921
|
-
shell: '/sbin/nologin'
|
|
926
|
+
let(:hiera_config) { 'spec/fixtures/hiera/hiera-rspec.yaml' }
|
|
922
927
|
```
|
|
923
928
|
|
|
924
|
-
|
|
929
|
+
Or alternatively, you could load the hiera configuration in the spec_helper to ensure it is available through all test files:
|
|
925
930
|
|
|
926
931
|
```ruby
|
|
927
|
-
|
|
928
|
-
|
|
932
|
+
RSpec.configure do |c|
|
|
933
|
+
c.hiera_config = 'spec/fixtures/hiera/hiera-rspec.yaml'
|
|
934
|
+
end
|
|
929
935
|
```
|
|
930
936
|
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
the
|
|
937
|
+
#### Test usage examples
|
|
938
|
+
|
|
939
|
+
Unlike with Hiera 3, Hiera 5 comes packaged with our Puppet agent and runs during Puppet runtime. This means that it is not really possible to
|
|
940
|
+
call the lookup function in the same way it previously worked. However, you can still test its functionality via dummy class instantiation:
|
|
941
|
+
|
|
942
|
+
The following test creates a dummny class that uses the lookup function within it. This should allow you to confirm that the lookup() function
|
|
943
|
+
works correctly (remember that this test uses your custom hiera parameters, and not your real ones).
|
|
935
944
|
|
|
936
945
|
```ruby
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
946
|
+
context 'dummy hiera test is implemented' do
|
|
947
|
+
let(:pre_condition) do
|
|
948
|
+
"class dummy($message) { }
|
|
949
|
+
class { 'dummy': message => lookup('message') }"
|
|
950
|
+
end
|
|
951
|
+
let(:hiera_config) { 'spec/fixtures/hiera/hiera-rspec.yaml' } # Only needed if the config has not been established in spec_helper
|
|
952
|
+
|
|
953
|
+
it { is_expected.to compile }
|
|
954
|
+
|
|
955
|
+
it 'loads ntpserver from Hiera' do
|
|
956
|
+
is_expected.to contain_class('dummy').with_message('Hello world!')
|
|
957
|
+
end
|
|
958
|
+
end
|
|
940
959
|
```
|
|
941
960
|
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
961
|
+
The next test ensures that autoloaded parameters work correctly within your classes:
|
|
962
|
+
|
|
963
|
+
```ruby
|
|
964
|
+
context 'dummy hiera test is implemented a second time' do
|
|
965
|
+
let(:pre_condition) do
|
|
966
|
+
"class dummy($message2) { }
|
|
967
|
+
include dummy"
|
|
968
|
+
end
|
|
969
|
+
let(:hiera_config) { 'spec/fixtures/hiera/hiera-rspec.yaml' } # Only needed if the config has not been established in spec_helper
|
|
970
|
+
|
|
971
|
+
it { is_expected.to compile }
|
|
972
|
+
|
|
973
|
+
it 'loads ntpserver from Hiera' do
|
|
974
|
+
is_expected.to contain_class('dummy').with_message2('foobar')
|
|
975
|
+
end
|
|
976
|
+
end
|
|
951
977
|
```
|
|
952
978
|
|
|
953
979
|
**Please note:** In-module hiera data depends on having a correct metadata.json file. It is
|
data/bin/rspec-puppet-init
CHANGED
|
@@ -53,13 +53,11 @@ module RSpec::Puppet
|
|
|
53
53
|
[puppet_setting, get_setting(example_group, rspec_setting)]
|
|
54
54
|
end.flatten
|
|
55
55
|
default_hash = { confdir: '/dev/null', vardir: '/dev/null' }
|
|
56
|
-
if defined?(Puppet::Test::TestHelper) && Puppet::Test::TestHelper.respond_to?(:app_defaults_for_tests, true)
|
|
57
|
-
default_hash.merge!(Puppet::Test::TestHelper.send(:app_defaults_for_tests))
|
|
58
|
-
end
|
|
56
|
+
default_hash.merge!(Puppet::Test::TestHelper.send(:app_defaults_for_tests)) if defined?(Puppet::Test::TestHelper) && Puppet::Test::TestHelper.respond_to?(:app_defaults_for_tests, true)
|
|
59
57
|
settings_hash = default_hash.merge(Hash[*settings])
|
|
60
58
|
if Gem.win_platform?
|
|
61
59
|
settings_hash.each_with_object(settings_hash) do |(k, v), h|
|
|
62
|
-
h[k] = v == '/dev/null' ? 'c:/nul/' : v
|
|
60
|
+
h[k] = (v == '/dev/null') ? 'c:/nul/' : v
|
|
63
61
|
end
|
|
64
62
|
end
|
|
65
63
|
|
|
@@ -101,9 +99,9 @@ module RSpec::Puppet
|
|
|
101
99
|
{
|
|
102
100
|
environments: loader,
|
|
103
101
|
current_environment: env,
|
|
104
|
-
loaders: Puppet::Pops::Loaders.new(env)
|
|
102
|
+
loaders: Puppet::Pops::Loaders.new(env),
|
|
105
103
|
},
|
|
106
|
-
'Setup rspec-puppet environments'
|
|
104
|
+
'Setup rspec-puppet environments',
|
|
107
105
|
)
|
|
108
106
|
end
|
|
109
107
|
|
|
@@ -119,9 +117,7 @@ module RSpec::Puppet
|
|
|
119
117
|
node.environment = current_environment
|
|
120
118
|
# Override $::environment to workaround PUP-5835, where Puppet otherwise
|
|
121
119
|
# stores a symbol for the parameter
|
|
122
|
-
if node.parameters['environment'] != node.parameters['environment'].to_s
|
|
123
|
-
node.parameters['environment'] = current_environment.name.to_s
|
|
124
|
-
end
|
|
120
|
+
node.parameters['environment'] = current_environment.name.to_s if node.parameters['environment'] != node.parameters['environment'].to_s
|
|
125
121
|
|
|
126
122
|
catalog = if exported
|
|
127
123
|
# Use the compiler directly to skip the filtering done by the indirector
|
|
@@ -148,7 +144,7 @@ module RSpec::Puppet
|
|
|
148
144
|
%i[environmentpath environmentpath],
|
|
149
145
|
%i[hiera_config hiera_config],
|
|
150
146
|
%i[strict_variables strict_variables],
|
|
151
|
-
%i[vendormoduledir vendormoduledir]
|
|
147
|
+
%i[vendormoduledir vendormoduledir],
|
|
152
148
|
]
|
|
153
149
|
end
|
|
154
150
|
|
|
@@ -187,7 +183,7 @@ module RSpec::Puppet
|
|
|
187
183
|
|
|
188
184
|
def self.get
|
|
189
185
|
[
|
|
190
|
-
['7.11', Base]
|
|
186
|
+
['7.11', Base],
|
|
191
187
|
].each do |(version, klass)|
|
|
192
188
|
return klass.new if Puppet::Util::Package.versioncmp(Puppet.version, version) >= 0
|
|
193
189
|
end
|
data/lib/rspec-puppet/consts.rb
CHANGED
|
@@ -5,24 +5,24 @@ module RSpec::Puppet::Consts
|
|
|
5
5
|
posix: {
|
|
6
6
|
'File::PATH_SEPARATOR' => ':',
|
|
7
7
|
'File::ALT_SEPARATOR' => nil,
|
|
8
|
-
'Pathname::SEPARATOR_PAT' => /#{Regexp.quote('/')}
|
|
8
|
+
'Pathname::SEPARATOR_PAT' => /#{Regexp.quote('/')}/,
|
|
9
9
|
},
|
|
10
10
|
windows: {
|
|
11
11
|
'File::PATH_SEPARATOR' => ';',
|
|
12
12
|
'File::ALT_SEPARATOR' => '\\',
|
|
13
|
-
'Pathname::SEPARATOR_PAT' => /[#{Regexp.quote('\\')}#{Regexp.quote('/')}]
|
|
14
|
-
}
|
|
13
|
+
'Pathname::SEPARATOR_PAT' => /[#{Regexp.quote('\\')}#{Regexp.quote('/')}]/,
|
|
14
|
+
},
|
|
15
15
|
}.freeze
|
|
16
16
|
|
|
17
17
|
FEATURES = {
|
|
18
18
|
posix: {
|
|
19
19
|
posix: true,
|
|
20
|
-
microsoft_windows: false
|
|
20
|
+
microsoft_windows: false,
|
|
21
21
|
},
|
|
22
22
|
windows: {
|
|
23
23
|
posix: false,
|
|
24
|
-
microsoft_windows: true
|
|
25
|
-
}
|
|
24
|
+
microsoft_windows: true,
|
|
25
|
+
},
|
|
26
26
|
}.freeze
|
|
27
27
|
|
|
28
28
|
def self.stub_consts_for(platform)
|
|
@@ -232,9 +232,7 @@ module RSpec::Puppet
|
|
|
232
232
|
end
|
|
233
233
|
|
|
234
234
|
# This is not available on RSpec 2.x
|
|
235
|
-
if coverage_results.execution_result.respond_to?(:pending_message)
|
|
236
|
-
coverage_results.execution_result.pending_message = report[:text]
|
|
237
|
-
end
|
|
235
|
+
coverage_results.execution_result.pending_message = report[:text] if coverage_results.execution_result.respond_to?(:pending_message)
|
|
238
236
|
else
|
|
239
237
|
puts "The desired coverage must be 0 <= x <= 100, not '#{coverage_desired.inspect}'"
|
|
240
238
|
end
|
|
@@ -259,7 +257,7 @@ module RSpec::Puppet
|
|
|
259
257
|
text = [
|
|
260
258
|
"Total resources: #{report[:total]}",
|
|
261
259
|
"Touched resources: #{report[:touched]}",
|
|
262
|
-
"Resource coverage: #{report[:coverage]}%"
|
|
260
|
+
"Resource coverage: #{report[:coverage]}%",
|
|
263
261
|
]
|
|
264
262
|
|
|
265
263
|
if (report[:untouched]).positive?
|
|
@@ -341,7 +339,7 @@ module RSpec::Puppet
|
|
|
341
339
|
|
|
342
340
|
def to_hash
|
|
343
341
|
{
|
|
344
|
-
touched: touched
|
|
342
|
+
touched: touched?,
|
|
345
343
|
}
|
|
346
344
|
end
|
|
347
345
|
|
|
@@ -86,7 +86,7 @@ module RSpec::Puppet
|
|
|
86
86
|
|
|
87
87
|
def find_function(function_name = self.class.top_level_description)
|
|
88
88
|
with_vardir do
|
|
89
|
-
|
|
89
|
+
adapter.current_environment
|
|
90
90
|
|
|
91
91
|
context_overrides = compiler.context_overrides
|
|
92
92
|
func = nil
|
|
@@ -99,9 +99,7 @@ module RSpec::Puppet
|
|
|
99
99
|
|
|
100
100
|
return func if func.func
|
|
101
101
|
|
|
102
|
-
if Puppet::Parser::Functions.function(function_name)
|
|
103
|
-
V3FunctionWrapper.new(function_name, scope.method(:"function_#{function_name}"))
|
|
104
|
-
end
|
|
102
|
+
V3FunctionWrapper.new(function_name, scope.method(:"function_#{function_name}")) if Puppet::Parser::Functions.function(function_name)
|
|
105
103
|
end
|
|
106
104
|
end
|
|
107
105
|
|
|
@@ -148,7 +146,7 @@ module RSpec::Puppet
|
|
|
148
146
|
|
|
149
147
|
node_options = {
|
|
150
148
|
parameters: fact_values,
|
|
151
|
-
facts: node_facts
|
|
149
|
+
facts: node_facts,
|
|
152
150
|
}
|
|
153
151
|
|
|
154
152
|
stub_facts! fact_values
|
|
@@ -157,9 +155,9 @@ module RSpec::Puppet
|
|
|
157
155
|
|
|
158
156
|
Puppet.push_context(
|
|
159
157
|
{
|
|
160
|
-
trusted_information: Puppet::Context::TrustedInformation.new('remote', node_name, trusted_values)
|
|
158
|
+
trusted_information: Puppet::Context::TrustedInformation.new('remote', node_name, trusted_values),
|
|
161
159
|
},
|
|
162
|
-
'Context for spec trusted hash'
|
|
160
|
+
'Context for spec trusted hash',
|
|
163
161
|
)
|
|
164
162
|
|
|
165
163
|
compiler = Puppet::Parser::Compiler.new(node)
|
|
@@ -168,9 +166,9 @@ module RSpec::Puppet
|
|
|
168
166
|
Puppet.push_context(
|
|
169
167
|
{
|
|
170
168
|
loaders: loaders,
|
|
171
|
-
global_scope: compiler.context_overrides[:global_scope]
|
|
169
|
+
global_scope: compiler.context_overrides[:global_scope],
|
|
172
170
|
},
|
|
173
|
-
'set globals'
|
|
171
|
+
'set globals',
|
|
174
172
|
)
|
|
175
173
|
compiler
|
|
176
174
|
end
|
|
@@ -28,7 +28,7 @@ module RSpec::Puppet
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def failure_message
|
|
31
|
-
"expected that the type alias would #{description} but it raised the #{@error_msgs.length == 1 ? 'error' : 'errors'} #{@error_msgs.join(', ')}"
|
|
31
|
+
"expected that the type alias would #{description} but it raised the #{(@error_msgs.length == 1) ? 'error' : 'errors'} #{@error_msgs.join(', ')}"
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
def failure_message_when_negated
|
|
@@ -6,7 +6,7 @@ module RSpec::Puppet
|
|
|
6
6
|
DEFAULT_RESOURCES = [
|
|
7
7
|
'Class[main]',
|
|
8
8
|
'Class[Settings]',
|
|
9
|
-
'Stage[main]'
|
|
9
|
+
'Stage[main]',
|
|
10
10
|
].freeze
|
|
11
11
|
|
|
12
12
|
attr_reader :resource_type
|
|
@@ -46,10 +46,10 @@ module RSpec::Puppet
|
|
|
46
46
|
|
|
47
47
|
desc << "contain exactly #{@expected_number}"
|
|
48
48
|
if @type == 'class'
|
|
49
|
-
desc << (@expected_number == 1 ? 'class' : 'classes').to_s
|
|
49
|
+
desc << ((@expected_number == 1) ? 'class' : 'classes').to_s
|
|
50
50
|
else
|
|
51
51
|
desc << @resource_type.to_s unless @type == 'resource'
|
|
52
|
-
desc << (@expected_number == 1 ? 'resource' : 'resources').to_s
|
|
52
|
+
desc << ((@expected_number == 1) ? 'resource' : 'resources').to_s
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
desc.join(' ')
|
|
@@ -30,10 +30,10 @@ module RSpec::Puppet
|
|
|
30
30
|
self
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
def only_with(*args, &
|
|
33
|
+
def only_with(*args, &)
|
|
34
34
|
params = args.shift
|
|
35
35
|
@expected_params_count = (@expected_params_count || 0) + params.compact.size
|
|
36
|
-
with(params, &
|
|
36
|
+
with(params, &)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
def without(*args)
|
|
@@ -62,7 +62,7 @@ module RSpec::Puppet
|
|
|
62
62
|
self
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
-
def method_missing(method, *args, &
|
|
65
|
+
def method_missing(method, *args, &)
|
|
66
66
|
case method.to_s
|
|
67
67
|
when /^with_/
|
|
68
68
|
param = method.to_s.gsub(/^with_/, '')
|
|
@@ -83,7 +83,6 @@ module RSpec::Puppet
|
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
def matches?(catalogue)
|
|
86
|
-
ret = true
|
|
87
86
|
@catalogue = catalogue.is_a?(Puppet::Resource::Catalog) ? catalogue : catalogue.call
|
|
88
87
|
resource = @catalogue.resource(@referenced_type, @title)
|
|
89
88
|
|
|
@@ -104,14 +103,9 @@ module RSpec::Puppet
|
|
|
104
103
|
'name'
|
|
105
104
|
end
|
|
106
105
|
|
|
107
|
-
if @expected_params.none? { |param| param.first.to_s == namevar } && rsrc_hsh.key?(namevar.to_sym)
|
|
108
|
-
rsrc_hsh.delete(namevar.to_sym)
|
|
109
|
-
end
|
|
106
|
+
rsrc_hsh.delete(namevar.to_sym) if @expected_params.none? { |param| param.first.to_s == namevar } && rsrc_hsh.key?(namevar.to_sym)
|
|
110
107
|
|
|
111
|
-
if @expected_params_count && rsrc_hsh.size != @expected_params_count
|
|
112
|
-
ret = false
|
|
113
|
-
(@errors ||= []) << "exactly #{@expected_params_count} parameters but the catalogue contains #{rsrc_hsh.size}"
|
|
114
|
-
end
|
|
108
|
+
(@errors ||= []) << "exactly #{@expected_params_count} parameters but the catalogue contains #{rsrc_hsh.size}" if @expected_params_count && rsrc_hsh.size != @expected_params_count
|
|
115
109
|
|
|
116
110
|
check_params(rsrc_hsh, @expected_params, :should) if @expected_params.any?
|
|
117
111
|
check_params(rsrc_hsh, @expected_undef_params, :not) if @expected_undef_params.any?
|
|
@@ -207,12 +201,12 @@ module RSpec::Puppet
|
|
|
207
201
|
output = []
|
|
208
202
|
list.each do |param, value|
|
|
209
203
|
if value.nil?
|
|
210
|
-
output << "#{param} #{type == :not ? 'un' : ''}defined"
|
|
204
|
+
output << "#{param} #{(type == :not) ? 'un' : ''}defined"
|
|
211
205
|
else
|
|
212
|
-
a = type == :not ? '!' : '='
|
|
206
|
+
a = (type == :not) ? '!' : '='
|
|
213
207
|
b = value.is_a?(Regexp) ? '~' : '>'
|
|
214
208
|
output << if (param.to_s == 'content') && value.is_a?(String)
|
|
215
|
-
"#{param} #{type == :not ? 'not ' : ''} supplied string"
|
|
209
|
+
"#{param} #{(type == :not) ? 'not ' : ''} supplied string"
|
|
216
210
|
else
|
|
217
211
|
"#{param} #{a}#{b} #{value.inspect}"
|
|
218
212
|
end
|
|
@@ -223,33 +217,25 @@ module RSpec::Puppet
|
|
|
223
217
|
|
|
224
218
|
def check_befores(_catalogue, resource)
|
|
225
219
|
@befores.each do |ref|
|
|
226
|
-
unless precedes?(resource, canonicalize_resource(ref))
|
|
227
|
-
@errors << BeforeRelationshipError.new(resource.to_ref, ref)
|
|
228
|
-
end
|
|
220
|
+
@errors << BeforeRelationshipError.new(resource.to_ref, ref) unless precedes?(resource, canonicalize_resource(ref))
|
|
229
221
|
end
|
|
230
222
|
end
|
|
231
223
|
|
|
232
224
|
def check_requires(_catalogue, resource)
|
|
233
225
|
@requires.each do |ref|
|
|
234
|
-
unless precedes?(canonicalize_resource(ref), resource)
|
|
235
|
-
@errors << RequireRelationshipError.new(resource.to_ref, ref)
|
|
236
|
-
end
|
|
226
|
+
@errors << RequireRelationshipError.new(resource.to_ref, ref) unless precedes?(canonicalize_resource(ref), resource)
|
|
237
227
|
end
|
|
238
228
|
end
|
|
239
229
|
|
|
240
230
|
def check_notifies(_catalogue, resource)
|
|
241
231
|
@notifies.each do |ref|
|
|
242
|
-
unless notifies?(resource, canonicalize_resource(ref))
|
|
243
|
-
@errors << NotifyRelationshipError.new(resource.to_ref, ref)
|
|
244
|
-
end
|
|
232
|
+
@errors << NotifyRelationshipError.new(resource.to_ref, ref) unless notifies?(resource, canonicalize_resource(ref))
|
|
245
233
|
end
|
|
246
234
|
end
|
|
247
235
|
|
|
248
236
|
def check_subscribes(_catalogue, resource)
|
|
249
237
|
@subscribes.each do |ref|
|
|
250
|
-
unless notifies?(canonicalize_resource(ref), resource)
|
|
251
|
-
@errors << SubscribeRelationshipError.new(resource.to_ref, ref)
|
|
252
|
-
end
|
|
238
|
+
@errors << SubscribeRelationshipError.new(resource.to_ref, ref) unless notifies?(canonicalize_resource(ref), resource)
|
|
253
239
|
end
|
|
254
240
|
end
|
|
255
241
|
|
|
@@ -334,9 +320,7 @@ module RSpec::Puppet
|
|
|
334
320
|
before_refs = relationship_refs(u, :before) + relationship_refs(u, :notify)
|
|
335
321
|
require_refs = relationship_refs(v, :require) + relationship_refs(u, :subscribe)
|
|
336
322
|
|
|
337
|
-
if before_refs.include?(v.to_ref) || require_refs.include?(u.to_ref) || (
|
|
338
|
-
return true
|
|
339
|
-
end
|
|
323
|
+
return true if before_refs.include?(v.to_ref) || require_refs.include?(u.to_ref) || before_refs.intersect?(require_refs)
|
|
340
324
|
end
|
|
341
325
|
end
|
|
342
326
|
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
module RSpec::Puppet
|
|
4
4
|
module ManifestMatchers
|
|
5
|
-
def method_missing(method, *args, &
|
|
5
|
+
def method_missing(method, *args, &)
|
|
6
6
|
if /^(create|contain)_/.match?(method.to_s)
|
|
7
7
|
return RSpec::Puppet::ManifestMatchers::CreateGeneric.new(method, *args,
|
|
8
|
-
&
|
|
8
|
+
&)
|
|
9
9
|
end
|
|
10
10
|
if /^have_.+_count$/.match?(method.to_s)
|
|
11
11
|
return RSpec::Puppet::ManifestMatchers::CountGeneric.new(nil, args[0],
|
|
@@ -18,7 +18,7 @@ module RSpec::Puppet
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
module FunctionMatchers
|
|
21
|
-
def method_missing(method, *args, &
|
|
21
|
+
def method_missing(method, *args, &)
|
|
22
22
|
return RSpec::Puppet::FunctionMatchers::Run.new if method == :run
|
|
23
23
|
|
|
24
24
|
super
|
|
@@ -26,8 +26,8 @@ module RSpec::Puppet
|
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
module TypeMatchers
|
|
29
|
-
def method_missing(method,
|
|
30
|
-
return RSpec::Puppet::TypeMatchers::CreateGeneric.new(method,
|
|
29
|
+
def method_missing(method, ...)
|
|
30
|
+
return RSpec::Puppet::TypeMatchers::CreateGeneric.new(method, ...) if method == :be_valid_type
|
|
31
31
|
|
|
32
32
|
super
|
|
33
33
|
end
|
|
@@ -28,6 +28,8 @@ module RSpec::Puppet
|
|
|
28
28
|
actual = resource[@parameter]
|
|
29
29
|
expected = @value
|
|
30
30
|
|
|
31
|
+
actual = RSpec::Puppet::Sensitive.new(actual.unwrap) if actual.is_a?(Puppet::Pops::Types::PSensitiveType::Sensitive)
|
|
32
|
+
|
|
31
33
|
# Puppet flattens an array with a single value into just the value and
|
|
32
34
|
# this can cause confusion when testing as people expect when you put
|
|
33
35
|
# an array in, you'll get an array out.
|
|
@@ -19,9 +19,9 @@ module RSpec::Puppet
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def raise_error(
|
|
22
|
-
error = defined?(RSpec::Matchers::BuiltIn::RaiseError::UndefinedValue) ? RSpec::Matchers::BuiltIn::RaiseError::UndefinedValue : nil, message = nil, &
|
|
22
|
+
error = defined?(RSpec::Matchers::BuiltIn::RaiseError::UndefinedValue) ? RSpec::Matchers::BuiltIn::RaiseError::UndefinedValue : nil, message = nil, &
|
|
23
23
|
)
|
|
24
|
-
RaiseError.new(error, message, &
|
|
24
|
+
RaiseError.new(error, message, &)
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
end
|
|
@@ -143,7 +143,7 @@ module RSpec::Puppet
|
|
|
143
143
|
|
|
144
144
|
def failure_message_generic(type, _func_obj)
|
|
145
145
|
# message is mutable
|
|
146
|
-
message =
|
|
146
|
+
message = "expected #{func_name}(#{func_params}) to "
|
|
147
147
|
message << 'not ' if type == :should_not
|
|
148
148
|
|
|
149
149
|
if @has_expected_return
|
|
@@ -5,7 +5,7 @@ module RSpec
|
|
|
5
5
|
module Windows
|
|
6
6
|
module TaskSchedulerConstants
|
|
7
7
|
SYSTEM_USERS = ['NT AUTHORITY\SYSTEM', 'SYSTEM', 'NT AUTHORITY\LOCALSERVICE', 'NT AUTHORITY\NETWORKSERVICE',
|
|
8
|
-
'BUILTIN\USERS', 'USERS'].freeze
|
|
8
|
+
'BUILTIN\USERS', 'USERS',].freeze
|
|
9
9
|
|
|
10
10
|
# Triggers
|
|
11
11
|
|
|
@@ -221,7 +221,7 @@ module RSpec
|
|
|
221
221
|
CLSCTX_INPROC_SERVER = 0x1
|
|
222
222
|
CLSID_CTask = [0x148BD520, 0xA2AB, 0x11CE, 0xB1, 0x1F, 0x00, 0xAA, 0x00, 0x53, 0x05, 0x03].pack('LSSC8')
|
|
223
223
|
CLSID_CTaskScheduler = [0x148BD52A, 0xA2AB, 0x11CE, 0xB1, 0x1F, 0x00, 0xAA, 0x00, 0x53, 0x05,
|
|
224
|
-
0x03].pack('LSSC8')
|
|
224
|
+
0x03,].pack('LSSC8')
|
|
225
225
|
IID_ITaskScheduler = [0x148BD527, 0xA2AB, 0x11CE, 0xB1, 0x1F, 0x00, 0xAA, 0x00, 0x53, 0x05, 0x03].pack('LSSC8')
|
|
226
226
|
IID_ITask = [0x148BD524, 0xA2AB, 0x11CE, 0xB1, 0x1F, 0x00, 0xAA, 0x00, 0x53, 0x05, 0x03].pack('LSSC8')
|
|
227
227
|
IID_IPersistFile = [0x0000010b, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46].pack('LSSC8')
|
|
@@ -175,7 +175,7 @@ module Puppet
|
|
|
175
175
|
module_function :windows?
|
|
176
176
|
|
|
177
177
|
def actual_platform
|
|
178
|
-
@actual_platform ||= !!File::ALT_SEPARATOR ? :windows : :posix
|
|
178
|
+
@actual_platform ||= (!!File::ALT_SEPARATOR) ? :windows : :posix
|
|
179
179
|
end
|
|
180
180
|
module_function :actual_platform
|
|
181
181
|
|
|
@@ -366,7 +366,7 @@ end
|
|
|
366
366
|
# defined. This check only makes sense when applying the catalogue to a host
|
|
367
367
|
# and so can be safely stubbed out for unit testing.
|
|
368
368
|
Puppet::Type.type(:file).provide(:windows).class_eval do
|
|
369
|
-
|
|
369
|
+
instance_method(:supports_acl?) if respond_to?(:supports_acl?)
|
|
370
370
|
|
|
371
371
|
def supports_acl?(_path)
|
|
372
372
|
if RSpec::Puppet.rspec_puppet_example?
|
|
@@ -376,7 +376,7 @@ Puppet::Type.type(:file).provide(:windows).class_eval do
|
|
|
376
376
|
end
|
|
377
377
|
end
|
|
378
378
|
|
|
379
|
-
|
|
379
|
+
instance_method(:manages_symlinks?) if respond_to?(:manages_symlinks?)
|
|
380
380
|
|
|
381
381
|
def manages_symlinks?
|
|
382
382
|
if RSpec::Puppet.rspec_puppet_example?
|
|
@@ -394,7 +394,7 @@ module Kernel
|
|
|
394
394
|
alias old_require require
|
|
395
395
|
def require(path)
|
|
396
396
|
return if ['puppet/util/windows',
|
|
397
|
-
'win32/registry'].include?(path) && RSpec::Puppet.rspec_puppet_example? && Puppet::Util::Platform.pretend_windows?
|
|
397
|
+
'win32/registry',].include?(path) && RSpec::Puppet.rspec_puppet_example? && Puppet::Util::Platform.pretend_windows?
|
|
398
398
|
|
|
399
399
|
old_require(path)
|
|
400
400
|
end
|
|
@@ -24,6 +24,11 @@ module RSpec::Puppet
|
|
|
24
24
|
"Sensitive(#{@value.inspect})"
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
+
# @return the unwrapped value (needed to show diff)
|
|
28
|
+
def to_s
|
|
29
|
+
inspect
|
|
30
|
+
end
|
|
31
|
+
|
|
27
32
|
# Check for equality with another value.
|
|
28
33
|
# If compared to Puppet Sensitive type, it compares the wrapped values.
|
|
29
34
|
|
data/lib/rspec-puppet/setup.rb
CHANGED
|
@@ -55,7 +55,7 @@ module RSpec::Puppet
|
|
|
55
55
|
File.join('spec', 'hosts'),
|
|
56
56
|
File.join('spec', 'fixtures'),
|
|
57
57
|
File.join('spec', 'fixtures', 'manifests'),
|
|
58
|
-
File.join('spec', 'fixtures', 'modules')
|
|
58
|
+
File.join('spec', 'fixtures', 'modules'),
|
|
59
59
|
].each { |dir| safe_mkdir(dir, verbose) }
|
|
60
60
|
|
|
61
61
|
target = File.join('spec', 'fixtures', 'modules', module_name)
|
data/lib/rspec-puppet/support.rb
CHANGED
|
@@ -102,11 +102,11 @@ module RSpec::Puppet
|
|
|
102
102
|
trusted_external_data: trusted_external_data_hash,
|
|
103
103
|
ignored_cache_params: {
|
|
104
104
|
hiera_data_value: hiera_data_value,
|
|
105
|
-
rspec_config_values: rspec_config_values
|
|
106
|
-
}
|
|
105
|
+
rspec_config_values: rspec_config_values,
|
|
106
|
+
},
|
|
107
107
|
)
|
|
108
108
|
|
|
109
|
-
test_module = type == :host ? nil : class_name.split('::').first
|
|
109
|
+
test_module = (type == :host) ? nil : class_name.split('::').first
|
|
110
110
|
if type == :define
|
|
111
111
|
RSpec::Puppet::Coverage.add_filter(class_name, title)
|
|
112
112
|
else
|
|
@@ -128,7 +128,7 @@ module RSpec::Puppet
|
|
|
128
128
|
File.read(path)
|
|
129
129
|
elsif File.directory?(path)
|
|
130
130
|
# Read and concatenate all .pp files.
|
|
131
|
-
Dir[File.join(path, '*.pp')].
|
|
131
|
+
Dir[File.join(path, '*.pp')].map do |f|
|
|
132
132
|
File.read(f)
|
|
133
133
|
end.join("\n")
|
|
134
134
|
else
|
|
@@ -205,14 +205,14 @@ module RSpec::Puppet
|
|
|
205
205
|
def facts_hash(node)
|
|
206
206
|
base_facts = {
|
|
207
207
|
'clientversion' => Puppet::PUPPETVERSION,
|
|
208
|
-
'environment' => environment.to_s
|
|
208
|
+
'environment' => environment.to_s,
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
node_facts = {
|
|
212
212
|
'hostname' => node.split('.').first,
|
|
213
213
|
'fqdn' => node,
|
|
214
214
|
'domain' => node.split('.', 2).last,
|
|
215
|
-
'clientcert' => node
|
|
215
|
+
'clientcert' => node,
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
# Puppet 6.9.0 started setting a `serverip6` server fact which is set
|
|
@@ -220,14 +220,12 @@ module RSpec::Puppet
|
|
|
220
220
|
# by FacterDB don't have an `ipaddress6` fact set, then the normal Facter
|
|
221
221
|
# fact will be resolved, which can result in Ruby trying to load Windows
|
|
222
222
|
# only gems on Linux. This is only a problem if facter is used.
|
|
223
|
-
if RSpec.configuration.facter_implementation.to_sym == :facter
|
|
224
|
-
node_facts['ipaddress6'] = 'FE80:0000:0000:0000:AAAA:AAAA:AAAA'
|
|
225
|
-
end
|
|
223
|
+
node_facts['ipaddress6'] = 'FE80:0000:0000:0000:AAAA:AAAA:AAAA' if RSpec.configuration.facter_implementation.to_sym == :facter
|
|
226
224
|
|
|
227
225
|
networking_facts = {
|
|
228
226
|
'hostname' => node_facts['hostname'],
|
|
229
227
|
'fqdn' => node_facts['fqdn'],
|
|
230
|
-
'domain' => node_facts['domain']
|
|
228
|
+
'domain' => node_facts['domain'],
|
|
231
229
|
}
|
|
232
230
|
|
|
233
231
|
result_facts = if RSpec.configuration.default_facts.any?
|
|
@@ -275,9 +273,7 @@ module RSpec::Puppet
|
|
|
275
273
|
def trusted_facts_hash(_node_name)
|
|
276
274
|
extensions = {}
|
|
277
275
|
|
|
278
|
-
if RSpec.configuration.default_trusted_facts.any?
|
|
279
|
-
extensions.merge!(munge_facts(RSpec.configuration.default_trusted_facts))
|
|
280
|
-
end
|
|
276
|
+
extensions.merge!(munge_facts(RSpec.configuration.default_trusted_facts)) if RSpec.configuration.default_trusted_facts.any?
|
|
281
277
|
|
|
282
278
|
extensions.merge!(munge_facts(trusted_facts)) if respond_to?(:trusted_facts)
|
|
283
279
|
extensions
|
|
@@ -286,9 +282,7 @@ module RSpec::Puppet
|
|
|
286
282
|
def trusted_external_data_hash
|
|
287
283
|
external_data = {}
|
|
288
284
|
|
|
289
|
-
if RSpec.configuration.default_trusted_external_data.any?
|
|
290
|
-
external_data.merge!(munge_facts(RSpec.configuration.default_trusted_external_data))
|
|
291
|
-
end
|
|
285
|
+
external_data.merge!(munge_facts(RSpec.configuration.default_trusted_external_data)) if RSpec.configuration.default_trusted_external_data.any?
|
|
292
286
|
|
|
293
287
|
external_data.merge!(munge_facts(trusted_external_data)) if respond_to?(:trusted_external_data)
|
|
294
288
|
external_data
|
|
@@ -301,8 +295,7 @@ module RSpec::Puppet
|
|
|
301
295
|
server_facts['serverversion'] = Puppet.version.to_s
|
|
302
296
|
|
|
303
297
|
# And then add the server name and IP
|
|
304
|
-
{ 'servername' => 'fqdn',
|
|
305
|
-
'serverip' => 'ipaddress' }.each do |var, fact|
|
|
298
|
+
{ 'servername' => 'networking.fqdn', 'serverip' => 'networking.ip' }.each do |var, fact|
|
|
306
299
|
if (value = Puppet.runtime[:facter].value(fact))
|
|
307
300
|
server_facts[var] = value
|
|
308
301
|
else
|
|
@@ -311,8 +304,8 @@ module RSpec::Puppet
|
|
|
311
304
|
end
|
|
312
305
|
|
|
313
306
|
if server_facts['servername'].nil?
|
|
314
|
-
host = Puppet.runtime[:facter].value(
|
|
315
|
-
server_facts['servername'] = if (domain = Puppet.runtime[:facter].value(
|
|
307
|
+
host = Puppet.runtime[:facter].value('networking.hostname')
|
|
308
|
+
server_facts['servername'] = if (domain = Puppet.runtime[:facter].value('networking.domain'))
|
|
316
309
|
[host, domain].join('.')
|
|
317
310
|
else
|
|
318
311
|
host
|
|
@@ -382,7 +375,7 @@ module RSpec::Puppet
|
|
|
382
375
|
code: code,
|
|
383
376
|
exported: exported,
|
|
384
377
|
node_params: node_params,
|
|
385
|
-
trusted_external: {}
|
|
378
|
+
trusted_external: {},
|
|
386
379
|
})
|
|
387
380
|
end
|
|
388
381
|
|
|
@@ -422,9 +415,9 @@ module RSpec::Puppet
|
|
|
422
415
|
trusted_info.push(trusted_external_data)
|
|
423
416
|
Puppet.push_context(
|
|
424
417
|
{
|
|
425
|
-
trusted_information: Puppet::Context::TrustedInformation.new(*trusted_info)
|
|
418
|
+
trusted_information: Puppet::Context::TrustedInformation.new(*trusted_info),
|
|
426
419
|
},
|
|
427
|
-
'Context for spec trusted hash'
|
|
420
|
+
'Context for spec trusted hash',
|
|
428
421
|
)
|
|
429
422
|
|
|
430
423
|
node_obj.add_server_facts(server_facts_hash)
|
|
@@ -477,9 +470,7 @@ module RSpec::Puppet
|
|
|
477
470
|
Find.prune if %w[modules work-dir].any? do |dir|
|
|
478
471
|
file.relative_path_from(path).to_s.start_with?("spec/fixtures/#{dir}")
|
|
479
472
|
end
|
|
480
|
-
if file.basename.to_s.eql?(Puppet::Pops::Lookup::HieraConfig::CONFIG_FILE_NAME)
|
|
481
|
-
return @@fixture_hiera_configs[mod.name] = file.to_s
|
|
482
|
-
end
|
|
473
|
+
return @@fixture_hiera_configs[mod.name] = file.to_s if file.basename.to_s.eql?(Puppet::Pops::Lookup::HieraConfig::CONFIG_FILE_NAME)
|
|
483
474
|
end
|
|
484
475
|
end
|
|
485
476
|
@@fixture_hiera_configs[mod.name]
|
data/lib/rspec-puppet/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rspec-puppet
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 5.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tim Sharpe
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date:
|
|
13
|
+
date: 2026-09-03 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: rspec
|
|
@@ -26,6 +26,20 @@ dependencies:
|
|
|
26
26
|
- - "~>"
|
|
27
27
|
- !ruby/object:Gem::Version
|
|
28
28
|
version: '3.0'
|
|
29
|
+
- !ruby/object:Gem::Dependency
|
|
30
|
+
name: voxpupuli-rubocop
|
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
|
32
|
+
requirements:
|
|
33
|
+
- - "~>"
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: 3.0.0
|
|
36
|
+
type: :development
|
|
37
|
+
prerelease: false
|
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
39
|
+
requirements:
|
|
40
|
+
- - "~>"
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: 3.0.0
|
|
29
43
|
description: " RSpec tests for your Puppet manifests.\n"
|
|
30
44
|
email:
|
|
31
45
|
- tim@sharpe.id.au
|
|
@@ -36,6 +50,7 @@ extensions: []
|
|
|
36
50
|
extra_rdoc_files: []
|
|
37
51
|
files:
|
|
38
52
|
- CHANGELOG.md
|
|
53
|
+
- LICENSE
|
|
39
54
|
- README.md
|
|
40
55
|
- bin/rspec-puppet-init
|
|
41
56
|
- lib/rspec-puppet.rb
|
|
@@ -80,8 +95,7 @@ files:
|
|
|
80
95
|
homepage: https://github.com/puppetlabs/rspec-puppet/
|
|
81
96
|
licenses:
|
|
82
97
|
- MIT
|
|
83
|
-
metadata:
|
|
84
|
-
rubygems_mfa_required: 'true'
|
|
98
|
+
metadata: {}
|
|
85
99
|
post_install_message:
|
|
86
100
|
rdoc_options: []
|
|
87
101
|
require_paths:
|
|
@@ -90,14 +104,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
90
104
|
requirements:
|
|
91
105
|
- - ">="
|
|
92
106
|
- !ruby/object:Gem::Version
|
|
93
|
-
version:
|
|
107
|
+
version: 3.1.0
|
|
94
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
109
|
requirements:
|
|
96
110
|
- - ">="
|
|
97
111
|
- !ruby/object:Gem::Version
|
|
98
112
|
version: '0'
|
|
99
113
|
requirements: []
|
|
100
|
-
rubygems_version: 3.
|
|
114
|
+
rubygems_version: 3.4.19
|
|
101
115
|
signing_key:
|
|
102
116
|
specification_version: 4
|
|
103
117
|
summary: RSpec tests for your Puppet manifests
|