2014-05-07 11:49:25 +02:00
|
|
|
#! /usr/bin/env ruby -S rspec
|
2011-06-29 13:25:43 +02:00
|
|
|
dir = File.expand_path(File.dirname(__FILE__))
|
|
|
|
$LOAD_PATH.unshift File.join(dir, 'lib')
|
|
|
|
|
2014-03-05 21:43:58 +01:00
|
|
|
# So everyone else doesn't have to include this base constant.
|
|
|
|
module PuppetSpec
|
|
|
|
FIXTURE_DIR = File.join(dir = File.expand_path(File.dirname(__FILE__)), "fixtures") unless defined?(FIXTURE_DIR)
|
|
|
|
end
|
2011-06-29 13:25:43 +02:00
|
|
|
|
|
|
|
require 'puppet'
|
2014-03-05 21:43:58 +01:00
|
|
|
require 'rspec-puppet'
|
2012-07-20 01:14:37 +02:00
|
|
|
require 'puppetlabs_spec_helper/module_spec_helper'
|
2014-03-05 21:43:58 +01:00
|
|
|
require 'puppet_spec/verbose'
|
|
|
|
require 'puppet_spec/files'
|
|
|
|
require 'puppet_spec/settings'
|
|
|
|
require 'puppet_spec/fixtures'
|
|
|
|
require 'puppet_spec/matchers'
|
|
|
|
require 'puppet_spec/database'
|
|
|
|
require 'monkey_patches/alias_should_to_must'
|
2015-05-05 14:30:54 +02:00
|
|
|
require 'mocha/api'
|
2012-05-11 07:01:40 +02:00
|
|
|
|
2015-06-01 13:21:59 +02:00
|
|
|
# hack to enable all the expect syntax (like allow_any_instance_of) in rspec-puppet examples
|
|
|
|
RSpec::Mocks::Syntax.enable_expect(RSpec::Puppet::ManifestMatchers)
|
|
|
|
|
2012-10-25 19:43:51 +02:00
|
|
|
RSpec.configure do |config|
|
2015-06-01 13:21:59 +02:00
|
|
|
config.add_setting :puppet_future
|
|
|
|
#config.puppet_future = (ENV['FUTURE_PARSER'] == 'yes' or Puppet.version.to_f >= 4.0)
|
|
|
|
config.puppet_future = Puppet.version.to_f >= 4.0
|
|
|
|
|
2012-10-25 19:43:51 +02:00
|
|
|
config.before :each do
|
|
|
|
# Ensure that we don't accidentally cache facts and environment between
|
|
|
|
# test cases. This requires each example group to explicitly load the
|
|
|
|
# facts being exercised with something like
|
|
|
|
# Facter.collection.loader.load(:ipaddress)
|
|
|
|
Facter.clear
|
|
|
|
Facter.clear_messages
|
2015-04-16 01:46:09 +02:00
|
|
|
|
|
|
|
Puppet[:parser] = 'future' if ENV['FUTURE_PARSER'] == 'yes'
|
2015-06-01 13:21:59 +02:00
|
|
|
|
|
|
|
RSpec::Mocks.setup
|
|
|
|
end
|
|
|
|
|
|
|
|
config.after :each do
|
|
|
|
RSpec::Mocks.verify
|
|
|
|
RSpec::Mocks.teardown
|
2012-10-25 19:43:51 +02:00
|
|
|
end
|
|
|
|
end
|