aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore7
-rw-r--r--.puppet-lint.rc5
-rw-r--r--.travis.yml26
-rw-r--r--Gemfile29
-rw-r--r--Rakefile7
-rw-r--r--spec/spec.opts6
-rw-r--r--spec/spec_helper.rb46
7 files changed, 100 insertions, 26 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b5b7a00
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,7 @@
+pkg/
+Gemfile.lock
+vendor/
+spec/fixtures/
+.vagrant/
+.bundle/
+coverage/
diff --git a/.puppet-lint.rc b/.puppet-lint.rc
new file mode 100644
index 0000000..d8f5c59
--- /dev/null
+++ b/.puppet-lint.rc
@@ -0,0 +1,5 @@
+--fail-on-warnings
+--relative
+--no-80chars
+--no-documentation
+--no-class_inherits_from_params_class-check
diff --git a/.travis.yml b/.travis.yml
index 6d7c0f8..0e0b6c6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,15 +1,17 @@
+---
language: ruby
-rvm:
- - 1.8.7
- - 1.9.3
- - 2.0.0
- - ruby-head
-env:
- - PUPPET_GEM_VERSION=">= 3.0.0"
+bundler_args: --without development
+script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'"
matrix:
- allow_failures:
- - rvm: 2.0.0
- - rvm: ruby-head
+ fast_finish: true
include:
- - rvm: 1.8.7
- env: PUPPET_GEM_VERSION="~> 2.7"
+ - rvm: 1.8.7
+ env: PUPPET_GEM_VERSION="~> 2.7"
+ - rvm: 1.8.7
+ env: PUPPET_GEM_VERSION="~> 3.0"
+ - rvm: 1.9.3
+ env: PUPPET_GEM_VERSION="~> 3.0"
+ - rvm: 2.0.0
+ env: PUPPET_GEM_VERSION="~> 3.0"
+notifications:
+ email: false
diff --git a/Gemfile b/Gemfile
index a500d9e..cff878d 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,13 +1,24 @@
-source :rubygems
+source ENV['GEM_SOURCE'] || "https://rubygems.org"
-if ENV.key?('PUPPET_VERSION')
- puppetversion = "= #{ENV['PUPPET_VERSION']}"
+group :development, :test do
+ gem 'rake', :require => false
+ gem 'rspec-puppet', :require => false
+ gem 'puppetlabs_spec_helper', :require => false
+ gem 'puppet-lint', :require => false
+ gem 'pry', :require => false
+ gem 'simplecov', :require => false
+end
+
+if facterversion = ENV['FACTER_GEM_VERSION']
+ gem 'facter', facterversion, :require => false
+else
+ gem 'facter', :require => false
+end
+
+if puppetversion = ENV['PUPPET_GEM_VERSION']
+ gem 'puppet', puppetversion, :require => false
else
- puppetversion = ['>= 2.7']
+ gem 'puppet', :require => false
end
-gem 'rake'
-gem 'puppet-lint'
-gem 'rspec-puppet'
-gem 'puppet', puppetversion
-gem 'puppetlabs_spec_helper', '>= 0.4.0'
+# vim:ft=ruby
diff --git a/Rakefile b/Rakefile
index 4d31fec..ee78ce6 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,5 +1,6 @@
-require 'puppet-lint/tasks/puppet-lint'
require 'puppetlabs_spec_helper/rake_tasks'
+require 'puppet-lint/tasks/puppet-lint'
-task :default => [:spec, :lint]
-
+PuppetLint.configuration.fail_on_warnings
+PuppetLint.configuration.send('disable_80chars')
+PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
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