From ea0bde3edcd12244050f5f021a077a0bbcb5dc71 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 24 May 2024 19:49:11 +0200 Subject: [PATCH] require rspec-puppet-facts 5.x --- lib/voxpupuli/test/facts.rb | 22 +++++++++++++++++----- voxpupuli-test.gemspec | 4 ++-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/voxpupuli/test/facts.rb b/lib/voxpupuli/test/facts.rb index 057b396..9b3cd03 100644 --- a/lib/voxpupuli/test/facts.rb +++ b/lib/voxpupuli/test/facts.rb @@ -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 @@ -67,13 +71,21 @@ def normalize_module_name(name) end def add_stdlib_facts - 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| + os = RSpec.configuration.facterdb_string_keys ? facts['os'] : facts[:os] case os['family'].downcase when 'archlinux', 'debian', 'redhat' diff --git a/voxpupuli-test.gemspec b/voxpupuli-test.gemspec index eed4b25..a93c6e4 100644 --- a/voxpupuli-test.gemspec +++ b/voxpupuli-test.gemspec @@ -17,7 +17,7 @@ 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' @@ -25,7 +25,7 @@ Gem::Specification.new do |s| # 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