summaryrefslogtreecommitdiffstats
path: root/spec/spec_helper.rb
blob: 4e54d72357a45bece27c24e3b30064c0c06fabd0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'pathname'
dir = Pathname.new(__FILE__).parent
$LOAD_PATH.unshift(dir, dir + 'lib', dir + '../lib')

require 'mocha'
require 'puppet'
require 'puppet/string'
require 'rspec'

RSpec.configure do |config|
    config.mock_with :mocha

    config.before :each do
      # Set the confdir and vardir to gibberish so that tests
      # have to be correctly mocked.
      Puppet[:confdir] = "/dev/null"
      Puppet[:vardir] = "/dev/null"

      # Avoid opening ports to the outside world
      Puppet.settings[:bindaddress] = "127.0.0.1"

      @logs = []
      Puppet::Util::Log.newdestination(@logs)
    end

    config.after :each do
      Puppet.settings.clear

      @logs.clear
      Puppet::Util::Log.close_all
    end
end

# We need this because the RAL uses 'should' as a method.  This
# allows us the same behaviour but with a different method name.
class Object
    alias :must :should
end