summaryrefslogtreecommitdiff
path: root/spec/spec_helper.rb
blob: 1474db18d858fac3dc9c6ae8a459fad84b2053d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require 'puppet'
require 'rspec-puppet'
require 'tmpdir'

RSpec.configure do |c|
  c.before :each do
    # Create a temporary puppet confdir area and temporary site.pp so
    # when rspec-puppet runs we don't get a puppet error.
    @puppetdir = Dir.mktmpdir("ntp")
    manifestdir = File.join(@puppetdir, "manifests")
    Dir.mkdir(manifestdir)
    FileUtils.touch(File.join(manifestdir, "site.pp"))
    Puppet[:confdir] = @puppetdir
    Puppet.settings.send(:initialize_everything_for_tests) unless Puppet.version =~ /^2\.6/
  end

  c.after :each do
    Puppet.settings.send(:clear_everything_for_tests) unless Puppet.version =~ /^2\.6/
    FileUtils.remove_entry_secure(@puppetdir)
  end

  c.module_path = File.join(File.dirname(__FILE__), '../../')
end