From 7ff571c00c00796dde92a00b334f2a61df49726b Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 23 Mar 2024 18:20:04 +0100 Subject: [PATCH] rspec-puppet-facts: Require 3.0.0; set facterdb_string_keys->true --- lib/voxpupuli/test/facts.rb | 4 +++- lib/voxpupuli/test/spec_helper.rb | 2 ++ spec/facts_spec.rb | 7 +++---- spec/spec_helper.rb | 1 + voxpupuli-test.gemspec | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/voxpupuli/test/facts.rb b/lib/voxpupuli/test/facts.rb index ea33b6d..e6e039d 100644 --- a/lib/voxpupuli/test/facts.rb +++ b/lib/voxpupuli/test/facts.rb @@ -51,7 +51,9 @@ 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' } + add_custom_fact :systemd, ->(_os, facts) do + (RSpec.configuration.facterdb_string_keys ? facts['service_provider'] : facts[:service_provider]) == 'systemd' + end when 'puppetlabs/stdlib' add_stdlib_facts end diff --git a/lib/voxpupuli/test/spec_helper.rb b/lib/voxpupuli/test/spec_helper.rb index 6022b13..d654d31 100644 --- a/lib/voxpupuli/test/spec_helper.rb +++ b/lib/voxpupuli/test/spec_helper.rb @@ -17,6 +17,8 @@ # and 7.12+ and requires rspec-puppet 2.11.0+. config.facter_implementation = 'rspec' + config.facterdb_string_keys = true + config.after(:suite) do RSpec::Puppet::Coverage.report! end diff --git a/spec/facts_spec.rb b/spec/facts_spec.rb index 0b29bd7..22d9b29 100644 --- a/spec/facts_spec.rb +++ b/spec/facts_spec.rb @@ -1,5 +1,4 @@ require 'spec_helper' -require 'voxpupuli/test/facts' describe 'override_facts' do let(:base_facts) do @@ -132,7 +131,7 @@ it 'has systemd on Red Hat 7' do add_facts_for_metadata(metadata) facts = RspecPuppetFacts.with_custom_facts('redhat-7-x86_64', { - os: { 'family' => 'RedHat', 'release' => { 'major' => '7' } } + 'os' => { 'family' => 'RedHat', 'release' => { 'major' => '7' } } }) expect(facts['systemd']).to be true end @@ -140,7 +139,7 @@ it 'has no systemd on Red Hat 6' do add_facts_for_metadata(metadata) facts = RspecPuppetFacts.with_custom_facts('redhat-6-x86_64', { - os: {'family' => 'RedHat', 'release' => { 'major' => '6' }} + 'os' => {'family' => 'RedHat', 'release' => { 'major' => '6' }} }) expect(facts['systemd']).to be false end @@ -148,7 +147,7 @@ it 'has no systemd on openbsd' do add_facts_for_metadata(metadata) facts = RspecPuppetFacts.with_custom_facts('openbsd-6.4-x86_64', { - os: { 'family' => 'OpenBSD' } + 'os' => { 'family' => 'OpenBSD' } }) expect(facts['systemd']).to be false end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 73fb578..f1b254d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -23,3 +23,4 @@ end require 'rspec/core' +require 'voxpupuli/test/spec_helper' diff --git a/voxpupuli-test.gemspec b/voxpupuli-test.gemspec index 98d11f1..b6381ba 100644 --- a/voxpupuli-test.gemspec +++ b/voxpupuli-test.gemspec @@ -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', '~> 2.0', '>= 2.0.5' + s.add_runtime_dependency 'rspec-puppet-facts', '~> 3.0' s.add_runtime_dependency 'rspec-puppet-utils', '~> 3.4' # Rubocop