require 'thor' require 'chef' module Teststrap class Teststrap < Thor include Thor::Actions attr_accessor :cookbook_name default_task :generate_tests desc "generate_tests", "generate test files" def generate_tests @cookbook_name = current_directory_name puts "generating testfiles::" copy_file ".gitignore" copy_file ".rubocop.yml" copy_file "Berksfile" copy_file "chefignore" copy_file "Gemfile" copy_file "LICENSE" copy_file "rubocop-disabled.yml" copy_file "Strainerfile" template "spec/default_spec.rb" template "spec/chefspec_helper.rb" template "test/integration/default/serverspec/default_spec.rb" template "test/integration/default/serverspec/spec_helper.rb" template ".kitchen.yml" template "metadata.rb" template "README.md" remove_file "Thorfile" end no_commands do def current_directory_name Dir.pwd.split('/').last end def run_command(cmd) exec(cmd) end def self.source_root generator_files_path end def self.generator_files_path File.expand_path('../../generator_files', __FILE__) end end end end