|
1 require 'puppetlabs_spec_helper/module_spec_helper' |
|
2 require 'rspec-puppet-facts' |
|
3 include RspecPuppetFacts |
|
4 |
|
5 |
|
6 RSpec.configure do |c| |
|
7 c.include PuppetlabsSpec::Files |
|
8 |
|
9 c.before :each do |
|
10 # Store any environment variables away to be restored later |
|
11 @old_env = {} |
|
12 ENV.each_key {|k| @old_env[k] = ENV[k]} |
|
13 |
|
14 c.strict_variables = Gem::Version.new(Puppet.version) >= Gem::Version.new('3.5') |
|
15 Puppet.features.stubs(:root?).returns(true) |
|
16 end |
|
17 |
|
18 c.after :each do |
|
19 PuppetlabsSpec::Files.cleanup |
|
20 end |
|
21 end |
|
22 |
|
23 require 'pathname' |
|
24 dir = Pathname.new(__FILE__).parent |
|
25 Puppet[:modulepath] = File.join(dir, 'fixtures', 'modules') |
|
26 |
|
27 # There's no real need to make this version dependent, but it helps find |
|
28 # regressions in Puppet |
|
29 # |
|
30 # 1. Workaround for issue #16277 where default settings aren't initialised from |
|
31 # a spec and so the libdir is never initialised (3.0.x) |
|
32 # 2. Workaround for 2.7.20 that now only loads types for the current node |
|
33 # environment (#13858) so Puppet[:modulepath] seems to get ignored |
|
34 # 3. Workaround for 3.5 where context hasn't been configured yet, |
|
35 # ticket https://tickets.puppetlabs.com/browse/MODULES-823 |
|
36 # |
|
37 ver = Gem::Version.new(Puppet.version.split('-').first) |
|
38 if Gem::Requirement.new("~> 2.7.20") =~ ver || Gem::Requirement.new("~> 3.0.0") =~ ver || Gem::Requirement.new("~> 3.5") =~ ver || Gem::Requirement.new("~> 4.0") |
|
39 puts "augeasproviders: setting Puppet[:libdir] to work around broken type autoloading" |
|
40 # libdir is only a single dir, so it can only workaround loading of one external module |
|
41 Puppet[:libdir] = "#{Puppet[:modulepath]}/augeasproviders_core/lib" |
|
42 end |