aboutsummaryrefslogtreecommitdiff
path: root/spec/spec_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/spec_helper.rb')
-rw-r--r--spec/spec_helper.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 96f14d5..93f417a 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -42,6 +42,18 @@ if Dir.exist?(File.expand_path('../../lib', __FILE__))
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!