Suggest different variables to use if we want to tunnel both v4 and v6
[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)))
27   rescue => e
28     RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}"
29   end
30 end
31
32 RSpec.configure do |c|
33   c.default_facts = default_facts
34   c.before :each do
35     # set to strictest setting for testing
36     # by default Puppet runs at warning level
37     Puppet.settings[:strict] = :warning
38   end
39 end
40
41 def ensure_module_defined(module_name)
42   module_name.split('::').reduce(Object) do |last_module, next_module|
43     last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false)
44     last_module.const_get(next_module, false)
45   end
46 end
47
48 # 'spec_overrides' from sync.yml will appear below this line