diff --git a/.sync.yml b/.sync.yml index 6cc1a46..4b30250 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,8 +1,8 @@ --- Gemfile: optional: ':test': - gem: 'redis' - gem: 'mock_redis' spec/spec_helper.rb: - unmanaged: true + mock_with: ":mocha" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 58acef0..5904139 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,31 +1,22 @@ +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config + RSpec.configure do |c| c.mock_with :mocha end -require 'puppetlabs_spec_helper/module_spec_helper' -require 'rspec-puppet-facts' -include RspecPuppetFacts - -if ENV['DEBUG'] - Puppet::Util::Log.level = :debug - Puppet::Util::Log.newdestination(:console) -end +# puppetlabs_spec_helper will set up coverage if the env variable is set. +# We want to do this if lib exists and it hasn't been explicitly set. +ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../../lib', __FILE__)) -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 +require 'voxpupuli/test/spec_helper' - # Coverage generation - c.after(:suite) do - RSpec::Puppet::Coverage.report! +if File.exist?(File.join(__dir__, 'default_module_facts.yml')) + facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml'))) + if facts + facts.each do |name, value| + add_custom_fact name.to_sym, value + end end end