Skip to content

Commit

Permalink
require rspec-puppet-facts 5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Jul 8, 2024
1 parent 4e53f97 commit ea0bde3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
22 changes: 17 additions & 5 deletions lib/voxpupuli/test/facts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ def add_facts_for_metadata(metadata)
metadata['dependencies'].each do |dependency|
case normalize_module_name(dependency['name'])
when 'camptocamp/systemd', 'puppet/systemd'
add_custom_fact :systemd, ->(_os, facts) { facts[:service_provider] == 'systemd' }
if RSpec.configuration.facterdb_string_keys
add_custom_fact 'systemd', ->(_os, facts) { facts['service_provider'] == 'systemd' }
else
add_custom_fact :systemd, ->(_os, facts) { facts[:service_provider] == 'systemd' }
end
when 'puppetlabs/stdlib'
add_stdlib_facts
end
Expand All @@ -67,13 +71,21 @@ def normalize_module_name(name)
end

def add_stdlib_facts

Check failure on line 73 in lib/voxpupuli/test/facts.rb

View workflow job for this annotation

GitHub Actions / rubocop

Metrics/AbcSize: Assignment Branch Condition size for add_stdlib_facts is too high. [<3, 21, 13> 24.88/18] (http://c2.com/cgi/wiki?AbcMetric, https://en.wikipedia.org/wiki/ABC_Software_Metric)

Check failure on line 73 in lib/voxpupuli/test/facts.rb

View workflow job for this annotation

GitHub Actions / rubocop

Metrics/CyclomaticComplexity: Cyclomatic complexity for add_stdlib_facts is too high. [12/10]

Check failure on line 73 in lib/voxpupuli/test/facts.rb

View workflow job for this annotation

GitHub Actions / rubocop

Metrics/MethodLength: Method has too many lines. [31/24] (https://rubystyle.guide#short-methods)
add_custom_fact :puppet_environmentpath, '/etc/puppetlabs/code/environments'
add_custom_fact :puppet_vardir, '/opt/puppetlabs/puppet/cache'
add_custom_fact :root_home, '/root'
if RSpec.configuration.facterdb_string_keys
add_custom_fact 'puppet_environmentpath', '/etc/puppetlabs/code/environments'
add_custom_fact 'puppet_vardir', '/opt/puppetlabs/puppet/cache'
add_custom_fact 'root_home', '/root'
else
add_custom_fact :puppet_environmentpath, '/etc/puppetlabs/code/environments'
add_custom_fact :puppet_vardir, '/opt/puppetlabs/puppet/cache'
add_custom_fact :root_home, '/root'
end

# Rough conversion of grepping in the puppet source:
# grep defaultfor lib/puppet/provider/service/*.rb
add_custom_fact :service_provider, lambda { |_os, facts|
service_provider = RSpec.configuration.facterdb_string_keys ? 'service_provider' : :service_provider
add_custom_fact service_provider, lambda { |_os, facts|

Check failure on line 88 in lib/voxpupuli/test/facts.rb

View workflow job for this annotation

GitHub Actions / rubocop

Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning. (https://rubystyle.guide#empty-lines-around-bodies)
os = RSpec.configuration.facterdb_string_keys ? facts['os'] : facts[:os]
case os['family'].downcase
when 'archlinux', 'debian', 'redhat'
Expand Down
4 changes: 2 additions & 2 deletions voxpupuli-test.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ Gem::Specification.new do |s|
s.add_runtime_dependency 'rake', '~> 13.0', '>= 13.0.6'

# Testing
s.add_runtime_dependency 'facterdb', '~> 2.1'
s.add_runtime_dependency 'facterdb', '~> 3.1'
s.add_runtime_dependency 'metadata-json-lint', '~> 4.0'
s.add_runtime_dependency 'parallel_tests', '~> 4.2'
s.add_runtime_dependency 'puppetlabs_spec_helper', '~> 7.3'
# lazy dependency of the `validate` task. Will check the REFERENCE.md
# 3.0.0 and later require Ruby 2.7
s.add_runtime_dependency 'puppet-strings', '~> 4.0'
s.add_runtime_dependency 'rspec-puppet', '~> 4.0'
s.add_runtime_dependency 'rspec-puppet-facts', '~> 4.0'
s.add_runtime_dependency 'rspec-puppet-facts', '~> 5.0'
s.add_runtime_dependency 'rspec-puppet-utils', '~> 3.4'

# Rubocop
Expand Down

0 comments on commit ea0bde3

Please sign in to comment.