1
dir = File.expand_path(File.dirname(__FILE__))
2
$LOAD_PATH.unshift File.join(dir, 'lib')
4
# Don't want puppet getting the command line arguments for rake or autotest
10
require 'rspec/expectations'
12
# So everyone else doesn't have to include this base constant.
14
FIXTURE_DIR = File.join(dir = File.expand_path(File.dirname(__FILE__)), "fixtures") unless defined?(FIXTURE_DIR)
20
require 'puppet_spec/verbose'
21
require 'puppet_spec/files'
22
require 'puppet_spec/fixtures'
23
require 'puppet_spec/matchers'
24
require 'monkey_patches/alias_should_to_must'
25
require 'monkey_patches/publicize_methods'
27
Pathname.glob("#{dir}/shared_behaviours/**/*.rb") do |behaviour|
28
require behaviour.relative_path_from(Pathname.new(dir))
31
RSpec.configure do |config|
32
include PuppetSpec::Fixtures
34
config.mock_with :mocha
36
config.before :each do
39
# these globals are set by Application
40
$puppet_application_mode = nil
41
$puppet_application_name = nil
43
# REVISIT: I think this conceals other bad tests, but I don't have time to
44
# fully diagnose those right now. When you read this, please come tell me
45
# I suck for letting this float. --daniel 2011-04-21
48
# Set the confdir and vardir to gibberish so that tests
49
# have to be correctly mocked.
50
Puppet[:confdir] = "/dev/null"
51
Puppet[:vardir] = "/dev/null"
53
# Avoid opening ports to the outside world
54
Puppet.settings[:bindaddress] = "127.0.0.1"
57
Puppet::Util::Log.newdestination(Puppet::Test::LogCollector.new(@logs))
59
@log_level = Puppet::Util::Log.level
64
Puppet::Node::Environment.clear
65
Puppet::Util::Storage.clear
66
Puppet::Util::ExecutionStub.reset
68
PuppetSpec::Files.cleanup
71
Puppet::Util::Log.close_all
72
Puppet::Util::Log.level = @log_level