Skip to content

Instantly share code, notes, and snippets.

@vStone
Created November 30, 2012 11:53
Show Gist options
  • Save vStone/4175348 to your computer and use it in GitHub Desktop.
Save vStone/4175348 to your computer and use it in GitHub Desktop.
Rakefile for your puppet modules.
source :rubygems
gem 'rake'
gem 'rspec', '>2'
gem 'rspec-puppet'
gem 'puppetlabs_spec_helper'
## Optionally use puppet-lint for style checks.
#gem 'puppet-lint'
# For testing puppet 2.7 series.
gem 'puppet', '~>2.7.0'
# gem 'puppet' # for testing the latest
require 'rake'
require 'rspec/core/rake_task'
desc "Run all RSpec code examples"
RSpec::Core::RakeTask.new(:rspec) do |t|
t.rspec_opts = File.read("spec/spec.opts").chomp || ""
end
SPEC_SUITES = (Dir.entries('spec') - ['.', '..','fixtures']).select {|e| File.directory? "spec/#{e}" }
namespace :rspec do
SPEC_SUITES.each do |suite|
desc "Run #{suite} RSpec code examples"
RSpec::Core::RakeTask.new(suite) do |t|
t.pattern = "spec/#{suite}/**/*_spec.rb"
t.rspec_opts = File.read("spec/spec.opts").chomp || ""
end
end
end
task :default => :rspec
## So you have puppet-lint? Allow me to use it for you.
begin
if Gem::Specification::find_by_name('puppet-lint')
require 'puppet-lint/tasks/puppet-lint'
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "vendor/**/*.pp"]
PuppetLint.configuration.log_format = '%{path}:%{linenumber}:%{KIND}: %{message}'
task :default => [:rspec, :lint]
end
rescue Gem::LoadError
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment