Sha256: 0923e12b51f43dd90019bc2a4addf0f01dec057cc0146c0bc97ad1ba6af8d6c3

Contents?: true

Size: 1.03 KB

Versions: 6

Compression:

Stored size: 1.03 KB

Contents

context = ChefDK::Generator.context
cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
recipe_path = File.join(cookbook_dir, "recipes", "#{context.new_file_basename}.rb")
spec_helper_path = File.join(cookbook_dir, "spec", "spec_helper.rb")
spec_path = File.join(cookbook_dir, "spec", "unit", "recipes", "#{context.new_file_basename}_spec.rb")
inspec_path = File.join(cookbook_dir, "test", "recipes", "#{context.new_file_basename}.rb")

# Chefspec
directory "#{cookbook_dir}/spec/unit/recipes" do
  recursive true
end

cookbook_file spec_helper_path do
  action :create_if_missing
end

template spec_path do
  source "recipe_spec.rb.erb"
  helpers(ChefDK::Generator::TemplateHelper)
  action :create_if_missing
end

# Inspec
directory "#{cookbook_dir}/test/recipes" do
  recursive true
end

template inspec_path do
  source 'inspec_default_test.rb.erb'
  helpers(ChefDK::Generator::TemplateHelper)
  action :create_if_missing
end

# Recipe
template recipe_path do
  source "recipe.rb.erb"
  helpers(ChefDK::Generator::TemplateHelper)
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
chef-dk-1.0.3 lib/chef-dk/skeletons/code_generator/recipes/recipe.rb
chef-dk-0.19.6 lib/chef-dk/skeletons/code_generator/recipes/recipe.rb
chef-dk-0.18.30 lib/chef-dk/skeletons/code_generator/recipes/recipe.rb
chef-dk-0.18.26 lib/chef-dk/skeletons/code_generator/recipes/recipe.rb
chef-dk-0.17.17 lib/chef-dk/skeletons/code_generator/recipes/recipe.rb
chef-dk-0.16.28 lib/chef-dk/skeletons/code_generator/recipes/recipe.rb