Class: RSpecPuppetSupport

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet-check/rspec_puppet_support.rb

Overview

class to prepare spec directory for rspec puppet testing

Class Method Summary collapse

Class Method Details

.runObject

prepare the spec fixtures directory for rspec-puppet testing



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/puppet-check/rspec_puppet_support.rb', line 10

def self.run
  # ensure this method does not do anything inside module dependencies
  specdirs = Dir.glob('**/spec').reject { |dir| dir.include?('fixtures') }
  return if specdirs.empty?

  # setup fixtures for rspec-puppet testing
  specdirs.each do |specdir|
    # skip to next specdir if it does not seem like a puppet module
    next unless File.directory?("#{specdir}/../manifests")

    # change to module directory
    Dir.chdir("#{specdir}/..")

    # grab the module name from the directory name of the module to pass to file_setup
    file_setup(File.basename(Dir.pwd))

    # invoke dependency_setup for module dependencies if metadata.json present
    dependency_setup if File.file?('metadata.json')
  end
end