puppet-nslcd/spec/spec_helper.rb

45 lines
1.4 KiB
Ruby
Raw Normal View History

2015-04-16 18:04:30 -04:00
require 'puppetlabs_spec_helper/module_spec_helper'
2018-08-22 06:07:49 -04:00
require 'rspec-puppet-facts'
2015-04-16 18:04:30 -04:00
2018-08-22 06:07:49 -04:00
begin
require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb'))
rescue LoadError => loaderror
warn "Could not require spec_helper_local: #{loaderror.message}"
end
include RspecPuppetFacts
2015-04-16 18:04:30 -04:00
2018-08-22 06:07:49 -04:00
default_facts = {
puppetversion: Puppet.version,
facterversion: Facter.version,
}
default_facts_path = File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml'))
default_module_facts_path = File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml'))
if File.exist?(default_facts_path) && File.readable?(default_facts_path)
default_facts.merge!(YAML.safe_load(File.read(default_facts_path)))
end
if File.exist?(default_module_facts_path) && File.readable?(default_module_facts_path)
default_facts.merge!(YAML.safe_load(File.read(default_module_facts_path)))
end
RSpec.configure do |c|
c.default_facts = default_facts
2015-04-16 18:04:30 -04:00
c.before :each do
2018-08-22 06:07:49 -04:00
# set to strictest setting for testing
# by default Puppet runs at warning level
Puppet.settings[:strict] = :warning
2015-04-16 18:04:30 -04:00
end
2018-08-22 06:07:49 -04:00
end
2015-04-16 18:04:30 -04:00
2018-08-22 06:07:49 -04:00
def ensure_module_defined(module_name)
module_name.split('::').reduce(Object) do |last_module, next_module|
last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module)
last_module.const_get(next_module)
2015-04-16 18:04:30 -04:00
end
end
2015-04-23 14:32:48 -04:00
2018-08-22 06:07:49 -04:00
# 'spec_overrides' from sync.yml will appear below this line