voxpupuli-test 8.1.0 → 9.1.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +40 -1
  3. data/lib/voxpupuli/test/facts.rb +16 -5
  4. metadata +8 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4dd40401d3073603368776f98a93973f4a174469d47197de13fb0f767b37f3a4
4
- data.tar.gz: 8ff8722876be3395a538da16ffdbcdd280275d703e2de43b8583e7e08c533632
3
+ metadata.gz: de5c4c45c655748d32946dd4996b350123da84b4de37dcbdefad71d073a99f1e
4
+ data.tar.gz: 4688827b9faa18c63744ec5949051578e34e71496ca5e79cbf537231456bd425
5
5
  SHA512:
6
- metadata.gz: 7d31264b414af6224887a14b0ff6772daaf9f88899f5e289d5b55133e422f7597bad2d2a10c18d65887d5d16ec5069e585e852ab5e5c0ff876474c06b74ecdd4
7
- data.tar.gz: 8309011ea81518fd8704a6f36afe30278305ca77d3e4d9ce42c42f51a0566b66fd5c39eb1b310029b1ae8e9529d9e4d64f2486414f0881b20a1a85f24d18cd68
6
+ metadata.gz: 4812da35ffe384f2bf4a1914d26337be1a49bf0912a67d8170d1643783cb303bdef7016f66b3cb7631820aeebdd07d0d52dddac14b017b7ac62af1887dfc325b
7
+ data.tar.gz: 80cadbb87158f50124cde42336209ae013ffdc0d2862314a297c28b97c03395ccdfb6a24def7d85cf74ddb86773eb9b769419e49fe8b75323aa31234ed6e8501
data/README.md CHANGED
@@ -7,7 +7,9 @@
7
7
  [![RubyGem Version](https://img.shields.io/gem/v/voxpupuli-test.svg)](https://rubygems.org/gems/voxpupuli-test)
8
8
  [![RubyGem Downloads](https://img.shields.io/gem/dt/voxpupuli-test.svg)](https://rubygems.org/gems/voxpupuli-test)
9
9
 
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.
10
+ This is a helper Gem to test the various Vox Pupuli Puppet modules.
11
+ This Gem provides common functionality for rspec-puppet based testing and static code analysis.
12
+ The aim is to reduce the boiler plate and need for modulesync.
11
13
 
12
14
  ## Usage
13
15
 
@@ -36,6 +38,43 @@ inherit_gem:
36
38
  voxpupuli-test: rubocop.yml
37
39
  ```
38
40
 
41
+ To run the linter, the syntax checker and the unit tests:
42
+
43
+ ```sh
44
+ bundle exec rake test
45
+ ```
46
+
47
+ To run your all the unit tests:
48
+
49
+ ```sh
50
+ bundle exec rake spec
51
+ ```
52
+
53
+ To run a specific spec test set the `SPEC` variable:
54
+
55
+ ```sh
56
+ SPEC=spec/classes/foo_spec.rb bundle exec rake spec
57
+ ```
58
+
59
+ To run all the static code analysis and linting:
60
+
61
+ ```sh
62
+ bundle exec rake validate lint check rubocop
63
+ ```
64
+
65
+
66
+ To autocorrect Puppet files:
67
+
68
+ ```sh
69
+ bundle exec rake lint_fix
70
+ ```
71
+
72
+ To autocorrect Ruby files:
73
+
74
+ ```sh
75
+ bundle exec rake rubocop:autocorrect
76
+ ```
77
+
39
78
  ## Rake tasks
40
79
 
41
80
  ### `check:trailing_whitespace`
@@ -53,7 +53,11 @@ def add_facts_for_metadata(metadata)
53
53
  metadata['dependencies'].each do |dependency|
54
54
  case normalize_module_name(dependency['name'])
55
55
  when 'camptocamp/systemd', 'puppet/systemd'
56
- 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
57
61
  when 'puppetlabs/stdlib'
58
62
  add_stdlib_facts
59
63
  end
@@ -67,13 +71,20 @@ def normalize_module_name(name)
67
71
  end
68
72
 
69
73
  def add_stdlib_facts
70
- add_custom_fact :puppet_environmentpath, '/etc/puppetlabs/code/environments'
71
- add_custom_fact :puppet_vardir, '/opt/puppetlabs/puppet/cache'
72
- 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
73
83
 
74
84
  # Rough conversion of grepping in the puppet source:
75
85
  # grep defaultfor lib/puppet/provider/service/*.rb
76
- add_custom_fact :service_provider, lambda { |_os, facts|
86
+ service_provider = RSpec.configuration.facterdb_string_keys ? 'service_provider' : :service_provider
87
+ add_custom_fact service_provider, lambda { |_os, facts|
77
88
  os = RSpec.configuration.facterdb_string_keys ? facts['os'] : facts[:os]
78
89
  case os['family'].downcase
79
90
  when 'archlinux', 'debian', 'redhat'
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.1.0
4
+ version: 9.1.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-07-05 00:00:00.000000000 Z
11
+ date: 2024-09-06 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
@@ -106,28 +106,28 @@ dependencies:
106
106
  requirements:
107
107
  - - "~>"
108
108
  - !ruby/object:Gem::Version
109
- version: '4.0'
109
+ version: '5.0'
110
110
  type: :runtime
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
- version: '4.0'
116
+ version: '5.0'
117
117
  - !ruby/object:Gem::Dependency
118
118
  name: rspec-puppet-facts
119
119
  requirement: !ruby/object:Gem::Requirement
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