Class: PuppetCheck::Tasks

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/puppet-check/tasks.rb

Overview

the rake interface for PuppetCheck

Instance Method Summary collapse

Constructor Details

#initializeTasks

Returns a new instance of Tasks.



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
# File 'lib/puppet-check/tasks.rb', line 8

def initialize
  desc 'Execute all Puppet-Check checks'
  task puppetcheck: %w(puppetcheck:file puppetcheck:spec puppetcheck:beaker)

  namespace :puppetcheck do
    desc 'Execute Puppet-Check file checks'
    task :file do
      PuppetCheck.new.run(Dir.glob('*'))
    end

    desc 'Execute RSpec and RSpec-Puppet tests'
    RSpec::Core::RakeTask.new(:spec) do |task|
      RSpecPuppetSupport.run
      # generate tasks for all recognized directories and ensure spec tests inside module dependencies are ignored
      spec_dirs = Dir.glob('**/{classes,defines,facter,functions,hosts,puppet,unit,types}/**/*_spec.rb').reject { |dir| dir =~ /fixtures/ }
      task.pattern = spec_dirs.empty? ? 'skip_rspec' : spec_dirs
      task.rspec_opts = '-f json' if PuppetCheck.output_format == 'json'
    end

    desc 'Execute Beaker acceptance tests'
    RSpec::Core::RakeTask.new(:beaker) do |task|
      # generate tasks for all recognized directories and ensure acceptance tests inside module dependencies are ignored
      acceptance_dirs = Dir.glob('**/acceptance').reject { |dir| dir =~ /fixtures/ }
      task.pattern = acceptance_dirs.empty? ? 'skip_beaker' : acceptance_dirs
      task.rspec_opts = '-f json' if PuppetCheck.output_format == 'json'
    end
  end
end