forked from cargomedia/puppet-packages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
48 lines (40 loc) · 1.4 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require 'rake'
require 'rspec/core/rake_task'
require 'puppet-lint/tasks/puppet-lint'
require 'pathname'
PuppetLint.configuration.send('disable_arrow_alignment')
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.send('disable_documentation')
PuppetLint.configuration.ignore_paths = ["**/templates/**/*.pp"]
RSpec::Core::RakeTask.new(:test) do |t|
t.pattern = 'modules/*/spec/*/spec.rb'
end
namespace :test do
task :cleanup do
sh 'vagrant', 'halt', '--force'
end
module_dirs = Pathname.new('modules/').children.select { |c| c.directory? }
module_dirs.each do |module_dir|
module_name = module_dir.basename
specs = Dir.glob("#{module_dir}/spec/**/spec.rb")
next if specs.empty?
RSpec::Core::RakeTask.new(module_name) do |t|
t.pattern = "modules/#{module_name}/spec/**/spec.rb"
end
next unless specs.count > 1
namespace module_name.to_s do
specs.each do |spec|
specs_dir = "#{module_dir}/spec/"
spec_path_relative = File.dirname(spec).sub(Regexp.new(specs_dir), '')
spec_name = spec_path_relative.gsub('/', ':')
RSpec::Core::RakeTask.new(spec_name) do |t|
puts t.pattern = "modules/#{module_name}/spec/#{spec_path_relative}/spec.rb"
end
end
end
end
end
desc 'puppet validate'
task :validate do
sh 'puppet parser validate $(find modules -name "*.pp" -not -path "*/templates/*")'
end