voxpupuli-test 8.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 346b627b7545574730d917660e968df59460018ce2334d2301be061d1b1aabca
4
- data.tar.gz: 7cd65cb60f03e97283bd7ed532b4255720df4f74ab0294309c2667707d35a94a
3
+ metadata.gz: 2f069b7c77b1b12a06412e4e12c2ecada41007a174301a6af4d96e556018709c
4
+ data.tar.gz: e92c583e9d321d6de5fd99d6ab7d5491b0399a0b8dddeb800c48e6bcc1c9ff29
5
5
  SHA512:
6
- metadata.gz: 343acd06af0a11767fda3ddce8a4fd247545b2f04b1c85a6238c9c4d135ebe9f1079174abc135a9f33c2345fa9036fec831fbe58a4a971489322e5eec23c808e
7
- data.tar.gz: ed0d6b115b358c3d5a8b8ef6596428e633b7ae971d2fba7dd5f621787293c92adc1d9781f7c0f654d27bcf38399b0a3cb0b28da80a674e152e96b078d5c56349
6
+ metadata.gz: d9e326670942388f36b61164dc06dd83328d2fd1fe8a1f9d4db084a081e1c341b125658bbbf83d9ac2fc22263917333b6c2aa10bd87c4daa66f09eedae05ae0a
7
+ data.tar.gz: c1557d2bf6d4df55cccbee2d75c647fb1328fb919b3dbf504d514419979c89987eaf351a643920d4b1d84d02b9fbf3b5b691d6c329b81c33d5855646d28a3f22
data/README.md CHANGED
@@ -9,7 +9,8 @@
9
9
 
10
10
  This is a helper Gem to test the various Vox Pupuli Puppet modules. This Gem provides common functionality for rspec-puppet based testing. The aim is to reduce the boiler plate and need for modulesync.
11
11
 
12
- # Usage
12
+ ## Usage
13
+
13
14
  Add the `voxpupuli-test` Gem to your `Gemfile`:
14
15
 
15
16
  ```ruby
@@ -35,7 +36,17 @@ inherit_gem:
35
36
  voxpupuli-test: rubocop.yml
36
37
  ```
37
38
 
38
- # Fact handling
39
+ ## Rake tasks
40
+
41
+ ### `check:trailing_whitespace`
42
+
43
+ The rake task `check:trailing_whitespace` checks for trailing whitespace in all markdown files in the repository.
44
+ It has an exclude pattern for: `%r{^((modules|acceptance|\.?vendor|spec/fixtures|pkg)/|REFERENCE.md)}`
45
+
46
+ We recommend using the GitHub style guide for markdown files, which includes no trailing whitespace.
47
+ See [GitHub Markdown Style Guide](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax)
48
+
49
+ ## Fact handling
39
50
 
40
51
  The recommended method is using [rspec-puppet-facts](https://github.com/mcanevet/rspec-puppet-facts) and is set up by default. This means the tests are writting as follows:
41
52
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rspec-puppet-facts'
2
4
  include RspecPuppetFacts
3
5
 
@@ -51,7 +53,11 @@ def add_facts_for_metadata(metadata)
51
53
  metadata['dependencies'].each do |dependency|
52
54
  case normalize_module_name(dependency['name'])
53
55
  when 'camptocamp/systemd', 'puppet/systemd'
54
- add_custom_fact :systemd, ->(_os, facts) { facts[:service_provider] == 'systemd' }
56
+ if RSpec.configuration.facterdb_string_keys
57
+ add_custom_fact 'systemd', ->(_os, facts) { facts['service_provider'] == 'systemd' }
58
+ else
59
+ add_custom_fact :systemd, ->(_os, facts) { facts[:service_provider] == 'systemd' }
60
+ end
55
61
  when 'puppetlabs/stdlib'
56
62
  add_stdlib_facts
57
63
  end
@@ -60,39 +66,43 @@ end
60
66
 
61
67
  def normalize_module_name(name)
62
68
  return unless name
69
+
63
70
  name.sub('-', '/')
64
71
  end
65
72
 
66
73
  def add_stdlib_facts
67
- add_custom_fact :puppet_environmentpath, '/etc/puppetlabs/code/environments'
68
- add_custom_fact :puppet_vardir, '/opt/puppetlabs/puppet/cache'
69
- add_custom_fact :root_home, '/root'
74
+ if RSpec.configuration.facterdb_string_keys
75
+ add_custom_fact 'puppet_environmentpath', '/etc/puppetlabs/code/environments'
76
+ add_custom_fact 'puppet_vardir', '/opt/puppetlabs/puppet/cache'
77
+ add_custom_fact 'root_home', '/root'
78
+ else
79
+ add_custom_fact :puppet_environmentpath, '/etc/puppetlabs/code/environments'
80
+ add_custom_fact :puppet_vardir, '/opt/puppetlabs/puppet/cache'
81
+ add_custom_fact :root_home, '/root'
82
+ end
70
83
 
71
84
  # Rough conversion of grepping in the puppet source:
72
85
  # grep defaultfor lib/puppet/provider/service/*.rb
73
- add_custom_fact :service_provider, ->(_os, facts) do
86
+ service_provider = RSpec.configuration.facterdb_string_keys ? 'service_provider' : :service_provider
87
+ add_custom_fact service_provider, lambda { |_os, facts|
74
88
  os = RSpec.configuration.facterdb_string_keys ? facts['os'] : facts[:os]
75
89
  case os['family'].downcase
76
- when 'archlinux'
90
+ when 'archlinux', 'debian', 'redhat'
77
91
  'systemd'
78
92
  when 'darwin'
79
93
  'launchd'
80
- when 'debian'
81
- 'systemd'
82
94
  when 'freebsd'
83
95
  'freebsd'
84
96
  when 'gentoo'
85
97
  'openrc'
86
98
  when 'openbsd'
87
99
  'openbsd'
88
- when 'redhat'
89
- 'systemd'
90
100
  when 'suse'
91
- os['release']['major'].to_i >= 12 ? 'systemd' : 'redhat'
101
+ (os['release']['major'].to_i >= 12) ? 'systemd' : 'redhat'
92
102
  when 'windows'
93
103
  'windows'
94
104
  else
95
105
  'init'
96
106
  end
97
- end
107
+ }
98
108
  end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'puppetlabs_spec_helper/rake_tasks'
2
4
 
3
- PuppetLint.configuration.log_format = '%{path}:%{line}:%{check}:%{KIND}:%{message}'
5
+ PuppetLint.configuration.log_format = '%<path>s:%<line>s:%<check>s:%<KIND>s:%<message>s'
4
6
  # without this, puppet-lint always gives an exit code of 0
5
7
  PuppetLint.configuration.fail_on_warnings = true
6
8
 
@@ -12,15 +14,23 @@ task default: [:release_checks]
12
14
  namespace :check do
13
15
  desc 'Check for trailing whitespace'
14
16
  task :trailing_whitespace do
17
+ errors = []
18
+
15
19
  Dir.glob('**/*.md', File::FNM_DOTMATCH).sort.each do |filename|
16
20
  next if filename =~ %r{^((modules|acceptance|\.?vendor|spec/fixtures|pkg)/|REFERENCE.md)}
21
+
17
22
  File.foreach(filename).each_with_index do |line, index|
18
- if line =~ %r{\s\n$}
19
- puts "#{filename} has trailing whitespace on line #{index + 1}"
20
- exit 1
23
+ if line =~ /\s\n$/
24
+ errors << "#{filename} has trailing whitespace on line #{index + 1}"
21
25
  end
22
26
  end
23
27
  end
28
+
29
+ if errors.any?
30
+ errors.each { |error| puts error }
31
+ exit 1
32
+ end
24
33
  end
25
34
  end
35
+
26
36
  Rake::Task[:check].enhance ['check:trailing_whitespace']
@@ -1,11 +1,4 @@
1
- RSpec.configure do |config|
2
- # puppetlabs_spec_helper defaults to mocha but emits a deprecation warning
3
- # Vox Pupuli prefers rspec to avoid the deprecation warning unless explicitly
4
- # set
5
- if config.instance_variable_get(:@mock_framework).nil?
6
- config.mock_with :rspec
7
- end
8
- end
1
+ # frozen_string_literal: true
9
2
 
10
3
  require 'voxpupuli/test/facts'
11
4
  require 'puppetlabs_spec_helper/module_spec_helper'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voxpupuli-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.0
4
+ version: 9.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vox Pupuli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-12 00:00:00.000000000 Z
11
+ date: 2024-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '2.1'
39
+ version: '3.1'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '2.1'
46
+ version: '3.1'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: metadata-json-lint
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -120,14 +120,14 @@ dependencies:
120
120
  requirements:
121
121
  - - "~>"
122
122
  - !ruby/object:Gem::Version
123
- version: '4.0'
123
+ version: '5.0'
124
124
  type: :runtime
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
- version: '4.0'
130
+ version: '5.0'
131
131
  - !ruby/object:Gem::Dependency
132
132
  name: rspec-puppet-utils
133
133
  requirement: !ruby/object:Gem::Requirement
@@ -157,33 +157,33 @@ dependencies:
157
157
  - !ruby/object:Gem::Version
158
158
  version: 1.50.0
159
159
  - !ruby/object:Gem::Dependency
160
- name: rubocop-rspec
160
+ name: rubocop-rake
161
161
  requirement: !ruby/object:Gem::Requirement
162
162
  requirements:
163
163
  - - "~>"
164
164
  - !ruby/object:Gem::Version
165
- version: 2.20.0
165
+ version: 0.6.0
166
166
  type: :runtime
167
167
  prerelease: false
168
168
  version_requirements: !ruby/object:Gem::Requirement
169
169
  requirements:
170
170
  - - "~>"
171
171
  - !ruby/object:Gem::Version
172
- version: 2.20.0
172
+ version: 0.6.0
173
173
  - !ruby/object:Gem::Dependency
174
- name: rubocop-rake
174
+ name: rubocop-rspec
175
175
  requirement: !ruby/object:Gem::Requirement
176
176
  requirements:
177
177
  - - "~>"
178
178
  - !ruby/object:Gem::Version
179
- version: 0.6.0
179
+ version: 2.20.0
180
180
  type: :runtime
181
181
  prerelease: false
182
182
  version_requirements: !ruby/object:Gem::Requirement
183
183
  requirements:
184
184
  - - "~>"
185
185
  - !ruby/object:Gem::Version
186
- version: 0.6.0
186
+ version: 2.20.0
187
187
  - !ruby/object:Gem::Dependency
188
188
  name: voxpupuli-puppet-lint-plugins
189
189
  requirement: !ruby/object:Gem::Requirement
@@ -222,7 +222,6 @@ extra_rdoc_files: []
222
222
  files:
223
223
  - LICENSE
224
224
  - README.md
225
- - lib/voxpupuli/test.rb
226
225
  - lib/voxpupuli/test/facts.rb
227
226
  - lib/voxpupuli/test/rake.rb
228
227
  - lib/voxpupuli/test/spec_helper.rb
File without changes