Skip to content

Instantly share code, notes, and snippets.

@mgagne
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgagne/d308eb64c47c0e4dce01 to your computer and use it in GitHub Desktop.
Save mgagne/d308eb64c47c0e4dce01 to your computer and use it in GitHub Desktop.
Using Puppetfile instead of .fixtures.yml
require 'puppetlabs_spec_helper/rake_tasks'
Rake::Task[:spec_prep].clear
desc "Create the fixtures directory"
task :spec_prep do
FileUtils::mkdir_p("spec/fixtures/modules")
FileUtils::mkdir_p("spec/fixtures/manifests")
FileUtils::touch("spec/fixtures/manifests/site.pp")
sh "librarian-puppet install --path=spec/fixtures/modules"
# NOTE(mgagne) rspec-puppet does not handle multiple modulepath
# We need to symlink modules found in modules/ in spec/fixtures/modules
Dir['modules/*/'].each { |module_path|
module_name = File.basename(module_path)
fixture_module_path = "spec/fixtures/modules/#{module_name}"
module_path = File.expand_path module_path
FileUtils.rm_f fixture_module_path
FileUtils.ln_sf module_path, fixture_module_path
}
end
Rake::Task[:spec_clean].clear
desc "Clean up the fixtures directory"
task :spec_clean do
sh "librarian-puppet clean --path=spec/fixtures/modules"
if File.zero?("spec/fixtures/manifests/site.pp")
FileUtils::rm_f("spec/fixtures/manifests/site.pp")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment