Update stdlib and concat to 6.1.0 both
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / spec_helper.rb
1 RSpec.configure do |c|
2   c.mock_with :rspec
3 end
4
5 require 'puppetlabs_spec_helper/module_spec_helper'
6 require 'rspec-puppet-facts'
7
8 require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb'))
9
10 include RspecPuppetFacts
11
12 default_facts = {
13   puppetversion: Puppet.version,
14   facterversion: Facter.version,
15 }
16
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')),
20 ]
21
22 default_fact_files.each do |f|
23   next unless File.exist?(f) && File.readable?(f) && File.size?(f)
24
25   begin
26     default_facts.merge!(YAML.safe_load(File.read(f), [], [], true))
27   rescue => e
28     RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}"
29   end
30 end
31
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
35 end
36
37 RSpec.configure do |c|
38   c.default_facts = default_facts
39   c.before :each do
40     # set to strictest setting for testing
41     # by default Puppet runs at warning level
42     Puppet.settings[:strict] = :warning
43   end
44   c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT']
45   c.after(:suite) do
46   end
47 end
48
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)
55   end
56 end
57
58 # 'spec_overrides' from sync.yml will appear below this line