rspec-puppet-facts 3.0.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -2
- data/.rubocop_todo.yml +62 -5
- data/CHANGELOG.md +66 -12
- data/Gemfile +4 -4
- data/README.md +56 -29
- data/Rakefile +19 -7
- data/lib/rspec-puppet-facts/version.rb +1 -1
- data/lib/rspec-puppet-facts.rb +42 -58
- data/rspec-puppet-facts.gemspec +2 -2
- data/spec/fixtures/metadata.json +4 -5
- data/spec/rspec_puppet_facts_spec.rb +209 -322
- metadata +9 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da12216f356aa371b255a495fa7eb0f3d3eb8b553aac7eed5e17c3098540f8f8
|
4
|
+
data.tar.gz: d774a6780c00fc787131c80f7bcbdb277e8b80b16c9b121be38f1ed4126f7f8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5350e14d6a9c61a6d1f01a7cbf0773048b10d305dd0901199d760106c8aa8e98ab8aa9d506a44f7142dbf6399b6dadb11322bc9682f8145c92a8598d2c2c9511
|
7
|
+
data.tar.gz: 52c83ec12e7926331107efd13642e68232bad5906a92a88c8cdb765247635d02239f9e0f942b40a70cbbb23256d0de8d15486935f1225eb88fa981557ad0110f
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2024-06-09 17:48:43 UTC using RuboCop version 1.63.5.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -12,7 +12,7 @@ Performance/MapCompact:
|
|
12
12
|
Exclude:
|
13
13
|
- 'lib/rspec-puppet-facts.rb'
|
14
14
|
|
15
|
-
# Offense count:
|
15
|
+
# Offense count: 29
|
16
16
|
# Configuration parameters: Prefixes, AllowedPatterns.
|
17
17
|
# Prefixes: when, with, without
|
18
18
|
RSpec/ContextWording:
|
@@ -29,7 +29,7 @@ RSpec/ExpectInHook:
|
|
29
29
|
Exclude:
|
30
30
|
- 'spec/rspec_puppet_facts_spec.rb'
|
31
31
|
|
32
|
-
# Offense count:
|
32
|
+
# Offense count: 8
|
33
33
|
# This cop supports safe autocorrection (--autocorrect).
|
34
34
|
# Configuration parameters: EnforcedStyle.
|
35
35
|
# SupportedStyles: single_line_only, single_statement_only, disallow, require_implicit
|
@@ -52,14 +52,14 @@ RSpec/MessageSpies:
|
|
52
52
|
RSpec/MultipleExpectations:
|
53
53
|
Max: 2
|
54
54
|
|
55
|
-
# Offense count:
|
55
|
+
# Offense count: 40
|
56
56
|
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
|
57
57
|
# SupportedStyles: always, named_only
|
58
58
|
RSpec/NamedSubject:
|
59
59
|
Exclude:
|
60
60
|
- 'spec/rspec_puppet_facts_spec.rb'
|
61
61
|
|
62
|
-
# Offense count:
|
62
|
+
# Offense count: 13
|
63
63
|
# Configuration parameters: AllowedGroups.
|
64
64
|
RSpec/NestedGroups:
|
65
65
|
Max: 6
|
@@ -74,3 +74,60 @@ RSpec/StubbedMock:
|
|
74
74
|
Rake/Desc:
|
75
75
|
Exclude:
|
76
76
|
- 'Rakefile'
|
77
|
+
|
78
|
+
# Offense count: 6
|
79
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
80
|
+
# Configuration parameters: EnforcedStyle.
|
81
|
+
# SupportedStyles: always, always_true, never
|
82
|
+
Style/FrozenStringLiteralComment:
|
83
|
+
Exclude:
|
84
|
+
- 'Gemfile'
|
85
|
+
- 'Rakefile'
|
86
|
+
- 'lib/rspec-puppet-facts.rb'
|
87
|
+
- 'lib/rspec-puppet-facts/version.rb'
|
88
|
+
- 'spec/rspec_puppet_facts_spec.rb'
|
89
|
+
- 'spec/spec_helper.rb'
|
90
|
+
|
91
|
+
# Offense count: 1
|
92
|
+
Style/MixinUsage:
|
93
|
+
Exclude:
|
94
|
+
- 'spec/spec_helper.rb'
|
95
|
+
|
96
|
+
# Offense count: 3
|
97
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
98
|
+
# Configuration parameters: EnforcedStyle.
|
99
|
+
# SupportedStyles: literals, strict
|
100
|
+
Style/MutableConstant:
|
101
|
+
Exclude:
|
102
|
+
- 'lib/rspec-puppet-facts.rb'
|
103
|
+
- 'lib/rspec-puppet-facts/version.rb'
|
104
|
+
- 'spec/rspec_puppet_facts_spec.rb'
|
105
|
+
|
106
|
+
# Offense count: 1
|
107
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
108
|
+
# Configuration parameters: Methods.
|
109
|
+
Style/RedundantArgument:
|
110
|
+
Exclude:
|
111
|
+
- 'lib/rspec-puppet-facts.rb'
|
112
|
+
|
113
|
+
# Offense count: 1
|
114
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
115
|
+
Style/RedundantSort:
|
116
|
+
Exclude:
|
117
|
+
- 'lib/rspec-puppet-facts.rb'
|
118
|
+
|
119
|
+
# Offense count: 2
|
120
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
121
|
+
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
|
122
|
+
# AllowedMethods: present?, blank?, presence, try, try!
|
123
|
+
Style/SafeNavigation:
|
124
|
+
Exclude:
|
125
|
+
- 'lib/rspec-puppet-facts.rb'
|
126
|
+
|
127
|
+
# Offense count: 2
|
128
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
129
|
+
# Configuration parameters: RequireEnglish, EnforcedStyle.
|
130
|
+
# SupportedStyles: use_perl_names, use_english_names, use_builtin_english_names
|
131
|
+
Style/SpecialGlobalVars:
|
132
|
+
Exclude:
|
133
|
+
- 'lib/rspec-puppet-facts.rb'
|
data/CHANGELOG.md
CHANGED
@@ -1,33 +1,87 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [5.0.0](https://github.com/voxpupuli/rspec-puppet-facts/tree/5.0.0) (2024-07-04)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/voxpupuli/rspec-puppet-facts/compare/4.0.0...5.0.0)
|
6
|
+
|
7
|
+
**Breaking changes:**
|
8
|
+
|
9
|
+
- Switch to FacterDB 3 / drop legacy facts [\#187](https://github.com/voxpupuli/rspec-puppet-facts/pull/187) ([bastelfreak](https://github.com/bastelfreak))
|
10
|
+
|
11
|
+
**Implemented enhancements:**
|
12
|
+
|
13
|
+
- Deprecate symbolized facts [\#193](https://github.com/voxpupuli/rspec-puppet-facts/pull/193) ([bastelfreak](https://github.com/bastelfreak))
|
14
|
+
|
15
|
+
**Fixed bugs:**
|
16
|
+
|
17
|
+
- handle stringified facterversion properly [\#191](https://github.com/voxpupuli/rspec-puppet-facts/pull/191) ([bastelfreak](https://github.com/bastelfreak))
|
18
|
+
|
19
|
+
**Merged pull requests:**
|
20
|
+
|
21
|
+
- Update voxpupuli-rubocop requirement from ~\> 2.7.0 to ~\> 2.8.0 [\#192](https://github.com/voxpupuli/rspec-puppet-facts/pull/192) ([dependabot[bot]](https://github.com/apps/dependabot))
|
22
|
+
|
23
|
+
## [4.0.0](https://github.com/voxpupuli/rspec-puppet-facts/tree/4.0.0) (2024-06-10)
|
24
|
+
|
25
|
+
[Full Changelog](https://github.com/voxpupuli/rspec-puppet-facts/compare/3.0.0...4.0.0)
|
26
|
+
|
27
|
+
**Breaking changes:**
|
28
|
+
|
29
|
+
- Rely on modern facts [\#178](https://github.com/voxpupuli/rspec-puppet-facts/pull/178) ([ekohl](https://github.com/ekohl))
|
30
|
+
- Require FacterDB 2.x [\#176](https://github.com/voxpupuli/rspec-puppet-facts/pull/176) ([bastelfreak](https://github.com/bastelfreak))
|
31
|
+
|
32
|
+
**Implemented enhancements:**
|
33
|
+
|
34
|
+
- work with symbolized strings [\#175](https://github.com/voxpupuli/rspec-puppet-facts/pull/175) ([bastelfreak](https://github.com/bastelfreak))
|
35
|
+
|
36
|
+
**Merged pull requests:**
|
37
|
+
|
38
|
+
- rubocop: Fix Layout cops [\#182](https://github.com/voxpupuli/rspec-puppet-facts/pull/182) ([bastelfreak](https://github.com/bastelfreak))
|
39
|
+
- Use max\_by to determine the maximum value [\#181](https://github.com/voxpupuli/rspec-puppet-facts/pull/181) ([ekohl](https://github.com/ekohl))
|
40
|
+
- rubocop: Fix Style cops [\#180](https://github.com/voxpupuli/rspec-puppet-facts/pull/180) ([bastelfreak](https://github.com/bastelfreak))
|
41
|
+
- Use more native rspec matchers in tests [\#179](https://github.com/voxpupuli/rspec-puppet-facts/pull/179) ([ekohl](https://github.com/ekohl))
|
42
|
+
- Update voxpupuli-rubocop requirement from ~\> 2.6.0 to ~\> 2.7.0 [\#171](https://github.com/voxpupuli/rspec-puppet-facts/pull/171) ([dependabot[bot]](https://github.com/apps/dependabot))
|
43
|
+
|
3
44
|
## [3.0.0](https://github.com/voxpupuli/rspec-puppet-facts/tree/3.0.0) (2024-03-23)
|
4
45
|
|
5
46
|
[Full Changelog](https://github.com/voxpupuli/rspec-puppet-facts/compare/2.0.5...3.0.0)
|
6
47
|
|
7
48
|
**symbolized facts deprecation**
|
8
49
|
|
9
|
-
With the release of rspec-puppet-facts
|
50
|
+
With the release of rspec-puppet-facts 6.0.0 we will remove support for symbolized facts. At the moment people typically use this in their unit files:
|
10
51
|
|
11
52
|
```ruby
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
53
|
+
on_supported_os.each do |os, os_facts|
|
54
|
+
case os_facts[:os]['name']
|
55
|
+
when 'Archlinux'
|
56
|
+
context 'on Archlinux' do
|
57
|
+
it { is_expected.to contain_package('borg') }
|
58
|
+
end
|
59
|
+
when 'Ubuntu'
|
16
60
|
end
|
17
|
-
|
61
|
+
end
|
18
62
|
```
|
19
63
|
|
20
|
-
For history reasons the first level of facts were symbols. You will have to update it to strings with the
|
64
|
+
For history reasons the first level of facts were symbols. You will have to update it to strings with the 6.0.0 release:
|
21
65
|
|
22
66
|
```ruby
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
67
|
+
on_supported_os.each do |os, os_facts|
|
68
|
+
case os_facts['os']['name']
|
69
|
+
when 'Archlinux'
|
70
|
+
context 'on Archlinux' do
|
71
|
+
it { is_expected.to contain_package('borg') }
|
72
|
+
end
|
73
|
+
when 'Ubuntu'
|
27
74
|
end
|
28
|
-
|
75
|
+
end
|
29
76
|
```
|
30
77
|
|
78
|
+
As an alternative you can configure the old behaviour:
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
RSpec.configure do |c|
|
82
|
+
c.facterdb_string_keys = false
|
83
|
+
end
|
84
|
+
```
|
31
85
|
|
32
86
|
**Breaking changes:**
|
33
87
|
|
data/Gemfile
CHANGED
@@ -2,14 +2,14 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
gem 'facter', ENV
|
5
|
+
gem 'facter', ENV.fetch('FACTER_GEM_VERSION', nil), require: false
|
6
6
|
|
7
7
|
group :release do
|
8
8
|
gem 'faraday-retry', '~> 2.1', require: false
|
9
9
|
gem 'github_changelog_generator', '~> 1.16.4', require: false
|
10
10
|
end
|
11
11
|
|
12
|
-
group :coverage, optional: ENV['COVERAGE']!='yes' do
|
13
|
-
gem 'codecov', :
|
14
|
-
gem 'simplecov-console', :
|
12
|
+
group :coverage, optional: ENV['COVERAGE'] != 'yes' do
|
13
|
+
gem 'codecov', require: false
|
14
|
+
gem 'simplecov-console', require: false
|
15
15
|
end
|
data/README.md
CHANGED
@@ -22,7 +22,7 @@ If you're using Bundler to manage gems in your module repository, install `rspec
|
|
22
22
|
1. Add the following line to your `Gemfile`:
|
23
23
|
|
24
24
|
```ruby
|
25
|
-
gem 'rspec-puppet-facts', :
|
25
|
+
gem 'rspec-puppet-facts', require: false
|
26
26
|
```
|
27
27
|
|
28
28
|
2. Run `bundle install`.
|
@@ -54,38 +54,18 @@ By default, `rspec-puppet-facts` provides the facts only for `x86_64` architectu
|
|
54
54
|
* `'operatingsystem'` - The name of the operating system, as a string.
|
55
55
|
* `'operatingsystemrelease'` - An array of version numbers, as strings.
|
56
56
|
|
57
|
-
This is particularly useful if your module is split into operating system subclasses. For example, if you had a class called `myclass::debian` that you wanted to test against Debian
|
57
|
+
This is particularly useful if your module is split into operating system subclasses. For example, if you had a class called `myclass::debian` that you wanted to test against Debian 12 and Debian 11 on both `x86_64` _and_ `i386` architectures, you could write the following test:
|
58
58
|
|
59
59
|
```ruby
|
60
60
|
require 'spec_helper'
|
61
61
|
|
62
|
-
describe 'myclass::debian' do
|
63
|
-
test_on = {
|
64
|
-
:hardwaremodels => ['x86_64', 'i386'],
|
65
|
-
:supported_os => [
|
66
|
-
{
|
67
|
-
'operatingsystem' => 'Debian',
|
68
|
-
'operatingsystemrelease' => ['6', '7'],
|
69
|
-
},
|
70
|
-
],
|
71
|
-
}
|
72
|
-
|
73
|
-
on_supported_os(test_on).each do |os, os_facts|
|
74
|
-
let (:facts) { os_facts }
|
75
|
-
it { is_expected.to compile.with_all_deps }
|
76
|
-
end
|
77
|
-
end
|
78
|
-
```
|
79
|
-
Ruby 1.9 and later:
|
80
|
-
```ruby
|
81
|
-
require 'spec_helper'
|
82
|
-
|
83
62
|
describe 'myclass::raspbian' do
|
84
63
|
test_on = {
|
64
|
+
hardwaremodels: ['x86_64', 'i386'],
|
85
65
|
supported_os: [
|
86
66
|
{
|
87
67
|
'operatingsystem' => 'Debian',
|
88
|
-
'operatingsystemrelease' => ['
|
68
|
+
'operatingsystemrelease' => ['12', '11'],
|
89
69
|
},
|
90
70
|
],
|
91
71
|
}
|
@@ -98,10 +78,9 @@ end
|
|
98
78
|
|
99
79
|
## Specifying a default Facter version
|
100
80
|
|
101
|
-
By default, `
|
102
|
-
|
103
|
-
overridden by setting the `default_facter_version` RSpec setting in your
|
104
|
-
`spec/spec_helper.rb` file.
|
81
|
+
By default, `on_supported_os` will return the facts for the version of Facter that it has loaded. It will check for the loaded Puppet version and maps that to the Facter version that Perforce released in the matching AIO.
|
82
|
+
The mapping is stored in `ext/puppet_agent_components.json` (check the [maintenance](#maintenance) section for details) and computated in the `facter_version_for_puppet_version` method.
|
83
|
+
This behaviour can be overridden by setting the `default_facter_version` RSpec setting in your `spec/spec_helper.rb` file.
|
105
84
|
|
106
85
|
```ruby
|
107
86
|
RSpec.configure do |c|
|
@@ -109,6 +88,54 @@ RSpec.configure do |c|
|
|
109
88
|
end
|
110
89
|
```
|
111
90
|
|
91
|
+
## Symbolized vs stringified facts
|
92
|
+
|
93
|
+
For a long long time, the first level of keys in a factsets were symbols.
|
94
|
+
This was fine before there were structured facts, but structured facts ended up as nested hashes that always had strings.
|
95
|
+
This doesn't make sense and easy to get wrong.
|
96
|
+
The original data contains only strings so conversion actually costs performance.
|
97
|
+
|
98
|
+
The option to switch between symbolized vs stringified facts was introduced in [25634f4481f20f2fc7444e867928ca607234e33e](https://github.com/voxpupuli/rspec-puppet-facts/commit/25634f4481f20f2fc7444e867928ca607234e33e) (Release [1.9.5](https://github.com/voxpupuli/rspec-puppet-facts/blob/master/CHANGELOG.md#2019-07-29---release-195)), but version 5.0.0 has resolved various implementation bugs.
|
99
|
+
|
100
|
+
This can be configured like this:
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
RSpec.configure do |c|
|
104
|
+
c.facterdb_string_keys = false
|
105
|
+
end
|
106
|
+
```
|
107
|
+
|
108
|
+
In the 5.x release series of rspec-puppet-facts the default `false` is deprecated.
|
109
|
+
With the 6.0.0 release we will flip it to `true` (https://github.com/voxpupuli/rspec-puppet-facts/pull/189).
|
110
|
+
|
111
|
+
You may have the following rspec-puppet test using deprecated symbolized facts:
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
on_supported_os.each do |os, os_facts|
|
115
|
+
case os_facts[:os]['name']
|
116
|
+
when 'Archlinux'
|
117
|
+
context 'on Archlinux' do
|
118
|
+
it { is_expected.to contain_package('borg') }
|
119
|
+
end
|
120
|
+
when 'Ubuntu'
|
121
|
+
end
|
122
|
+
end
|
123
|
+
```
|
124
|
+
|
125
|
+
With the string facts, the same test looks like:
|
126
|
+
|
127
|
+
```ruby
|
128
|
+
on_supported_os.each do |os, os_facts|
|
129
|
+
case os_facts['os']['name']
|
130
|
+
when 'Archlinux'
|
131
|
+
context 'on Archlinux' do
|
132
|
+
it { is_expected.to contain_package('borg') }
|
133
|
+
end
|
134
|
+
when 'Ubuntu'
|
135
|
+
end
|
136
|
+
end
|
137
|
+
```
|
138
|
+
|
112
139
|
## Usage
|
113
140
|
|
114
141
|
Use the `on_supported_os` iterator to loop through all of your module's supported operating systems. This allows you to simplify your tests and remove a lot of duplicate code.
|
@@ -475,7 +502,7 @@ fact sets that only make sense in your environment or might contain sensitive in
|
|
475
502
|
To supply external facts to facterdb just set the `FACTERDB_SEARCH_PATHS` environment variable with one or more
|
476
503
|
paths to your facts.
|
477
504
|
|
478
|
-
When separating paths please use the default path separator character supported by your OS.
|
505
|
+
When separating paths please use the default path separator character supported by your OS.
|
479
506
|
* Unix/Linux/OSX = `:`
|
480
507
|
* Windows = `;`
|
481
508
|
|
data/Rakefile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
PUPPET_VERSIONS_PATH = File.join(__dir__, 'ext', 'puppet_agent_components.json')
|
2
2
|
|
3
3
|
begin
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'yard'
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
YARD::Rake::YardocTask.new
|
8
8
|
rescue LoadError
|
9
9
|
# yard is optional
|
10
10
|
end
|
@@ -40,8 +40,8 @@ namespace :puppet_versions do
|
|
40
40
|
|
41
41
|
output = `git status --porcelain #{PUPPET_VERSIONS_PATH}`
|
42
42
|
unless output.strip.empty?
|
43
|
-
|
44
|
-
|
43
|
+
warn "#{PUPPET_VERSIONS_PATH} is out of date."
|
44
|
+
warn 'Run the puppet_versions:update task to update it and commit the changes.'
|
45
45
|
raise
|
46
46
|
end
|
47
47
|
end
|
@@ -54,12 +54,24 @@ rescue LoadError
|
|
54
54
|
else
|
55
55
|
require 'rubygems'
|
56
56
|
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
57
|
-
config.exclude_labels = %w
|
57
|
+
config.exclude_labels = %w[duplicate question invalid wontfix wont-fix skip-changelog github_actions]
|
58
58
|
config.user = 'voxpupuli'
|
59
59
|
config.project = 'rspec-puppet-facts'
|
60
60
|
gem_version = Gem::Specification.load("#{config.project}.gemspec").version
|
61
61
|
config.future_release = gem_version
|
62
62
|
end
|
63
|
+
|
64
|
+
# Workaround for https://github.com/github-changelog-generator/github-changelog-generator/issues/715
|
65
|
+
require 'rbconfig'
|
66
|
+
if RbConfig::CONFIG['host_os'].include?('linux')
|
67
|
+
task :changelog do
|
68
|
+
puts 'Fixing line endings...'
|
69
|
+
changelog_file = File.join(__dir__, 'CHANGELOG.md')
|
70
|
+
changelog_txt = File.read(changelog_file)
|
71
|
+
new_contents = changelog_txt.gsub("\r\n", "\n")
|
72
|
+
File.open(changelog_file, 'w') { |file| file.puts new_contents }
|
73
|
+
end
|
74
|
+
end
|
63
75
|
end
|
64
76
|
|
65
77
|
begin
|