From e6287f2251fe5a645a88b5b17643fea37cb6c11d Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 1 Nov 2019 00:32:41 +0100 Subject: [PATCH] mock facter version based on puppet version --- spec/spec_helper.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 96f14d543..93f417a10 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -42,6 +42,18 @@ end RSpec.configure do |c| + # getting the correct facter version is tricky. We use facterdb as a source to mock facts + # see https://github.com/camptocamp/facterdb + # people might provide a specific facter version. In that case we use it. + # Otherwise we need to match the correct facter version to the used puppet version. + # as of 2019-10-31, puppet 5 ships facter 3.11 and puppet 6 ships facter 3.14 + # https://puppet.com/docs/puppet/5.5/about_agent.html + c.default_facter_version = if ENV['FACTERDB_FACTS_VERSION'] + ENV['FACTERDB_FACTS_VERSION'] + else + Gem::Dependency.new('', ENV['PUPPET_VERSION']).match?('', '5') ? '3.11.0' : '3.14.0' + end + # Coverage generation c.after(:suite) do RSpec::Puppet::Coverage.report!