Sha256: 0b3f5140c4661f44e24986400ce6aa18d9a422c1604a0840b8c87d71732e2ba1

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

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"
      copy_file "Thorfile"
      template "spec/default_spec.rb"
      template "spec/chefspec_helper.rb"
      template "test/integration/default/serverspec/localhost/default_spec.rb"
      template "test/integration/default/serverspec/spec_helper.rb"
      template ".kitchen.yml"
      template "metadata.rb"
      template "README.md"
    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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
teststrap-1.2.1 lib/teststrap.rb
teststrap-1.2.0 lib/teststrap.rb