5 require 'puppetlabs_spec_helper/module_spec_helper'
6 require 'rspec-puppet-facts'
8 require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb'))
10 include RspecPuppetFacts
13 puppetversion: Puppet.version,
14 facterversion: Facter.version,
17 default_fact_files = [
18 File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')),
19 File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')),
22 default_fact_files.each do |f|
23 next unless File.exist?(f) && File.readable?(f) && File.size?(f)
26 default_facts.merge!(YAML.safe_load(File.read(f), [], [], true))
28 RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}"
32 # read default_facts and merge them over what is provided by facterdb
33 default_facts.each do |fact, value|
34 add_custom_fact fact, value
37 RSpec.configure do |c|
38 c.default_facts = default_facts
40 # set to strictest setting for testing
41 # by default Puppet runs at warning level
42 Puppet.settings[:strict] = :warning
44 c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT']
49 # Ensures that a module is defined
50 # @param module_name Name of the module
51 def ensure_module_defined(module_name)
52 module_name.split('::').reduce(Object) do |last_module, next_module|
53 last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false)
54 last_module.const_get(next_module, false)
58 # 'spec_overrides' from sync.yml will appear below this line