aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorRaphaël Pinson <raphael.pinson@camptocamp.com>2014-10-20 09:43:30 +0200
committerRaphaël Pinson <raphael.pinson@camptocamp.com>2014-10-20 09:43:30 +0200
commit4cdd8a1456c0977bc9a55eeacce3890bfa317edf (patch)
tree2559a8d3121421f4f98fc99c35de1d0d9be945b2 /spec
parentb47fb8a3653b7b9ec99723815885e0f7b83909c8 (diff)
downloadpuppet-dhcp-4cdd8a1456c0977bc9a55eeacce3890bfa317edf.tar.gz
puppet-dhcp-4cdd8a1456c0977bc9a55eeacce3890bfa317edf.tar.bz2
Sync module
Diffstat (limited to 'spec')
-rw-r--r--spec/spec.opts6
-rw-r--r--spec/spec_helper.rb46
2 files changed, 50 insertions, 2 deletions
diff --git a/spec/spec.opts b/spec/spec.opts
new file mode 100644
index 0000000..91cd642
--- /dev/null
+++ b/spec/spec.opts
@@ -0,0 +1,6 @@
+--format
+s
+--colour
+--loadby
+mtime
+--backtrace
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 4edc964..adbb191 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,4 +1,46 @@
-require 'mocha'
-require 'rspec-puppet'
require 'puppetlabs_spec_helper/module_spec_helper'
+RSpec.configure do |c|
+ c.include PuppetlabsSpec::Files
+
+ c.before :each do
+ # Ensure that we don't accidentally cache facts and environment
+ # between test cases.
+ Facter::Util::Loader.any_instance.stubs(:load_all)
+ Facter.clear
+ Facter.clear_messages
+
+ # Store any environment variables away to be restored later
+ @old_env = {}
+ ENV.each_key {|k| @old_env[k] = ENV[k]}
+
+ if Gem::Version.new(`puppet --version`) >= Gem::Version.new('3.5')
+ Puppet.settings[:strict_variables]=true
+ end
+ end
+
+ c.after :each do
+ PuppetlabsSpec::Files.cleanup
+ end
+end
+
+require 'pathname'
+dir = Pathname.new(__FILE__).parent
+Puppet[:modulepath] = File.join(dir, 'fixtures', 'modules')
+
+# There's no real need to make this version dependent, but it helps find
+# regressions in Puppet
+#
+# 1. Workaround for issue #16277 where default settings aren't initialised from
+# a spec and so the libdir is never initialised (3.0.x)
+# 2. Workaround for 2.7.20 that now only loads types for the current node
+# environment (#13858) so Puppet[:modulepath] seems to get ignored
+# 3. Workaround for 3.5 where context hasn't been configured yet,
+# ticket https://tickets.puppetlabs.com/browse/MODULES-823
+#
+ver = Gem::Version.new(Puppet.version.split('-').first)
+if Gem::Requirement.new("~> 2.7.20") =~ ver || Gem::Requirement.new("~> 3.0.0") =~ ver || Gem::Requirement.new("~> 3.5") =~ ver
+ puts "augeasproviders: setting Puppet[:libdir] to work around broken type autoloading"
+ # libdir is only a single dir, so it can only workaround loading of one external module
+ Puppet[:libdir] = "#{Puppet[:modulepath]}/augeasproviders_core/lib"
+end