chef-gen-flavors 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ARUBA_STEPS.md +74 -0
- data/History.md +16 -0
- data/Manifest.txt +25 -30
- data/README.md +121 -16
- data/chef-gen-flavors.gemspec +8 -5
- data/lib/chef_gen/flavor_base.rb +42 -34
- data/lib/chef_gen/flavors.rb +36 -10
- data/lib/chef_gen/snippet/attributes.rb +13 -0
- data/lib/chef_gen/snippet/chef_spec.rb +84 -14
- data/lib/chef_gen/snippet/cookbook_base.rb +109 -23
- data/lib/chef_gen/snippet/example_file.rb +15 -0
- data/lib/chef_gen/snippet/example_template.rb +15 -0
- data/lib/chef_gen/snippet/git_init.rb +2 -0
- data/lib/chef_gen/snippet/recipes.rb +15 -0
- data/lib/chef_gen/snippet/resource_provider.rb +18 -0
- data/lib/chef_gen/snippet/standard_ignore.rb +56 -80
- data/lib/chef_gen/snippet/style_foodcritic.rb +51 -0
- data/lib/chef_gen/snippet/style_rubocop.rb +80 -0
- data/lib/chef_gen/snippet/style_tailor.rb +48 -0
- data/lib/chef_gen/snippet/test_kitchen.rb +70 -15
- data/lib/chef_gen/snippets.rb +2 -0
- data/shared/snippet/attributes/attributes_default_rb.erb +8 -0
- data/{.rspec → shared/snippet/chef_spec/_rspec.erb} +0 -0
- data/shared/snippet/chef_spec/spec_chef_runner_context_rb.erb +36 -0
- data/shared/snippet/chef_spec/spec_recipes_default_spec_rb.erb +7 -0
- data/shared/snippet/chef_spec/spec_spec_helper_rb.erb +95 -0
- data/shared/snippet/cookbookbase/Berksfile.erb +5 -0
- data/shared/snippet/cookbookbase/CHANGELOG_md.erb +5 -0
- data/shared/snippet/cookbookbase/Gemfile.erb +7 -0
- data/shared/snippet/cookbookbase/Guardfile.erb +10 -0
- data/shared/snippet/cookbookbase/README_md.erb +92 -0
- data/shared/snippet/cookbookbase/Rakefile.erb +20 -0
- data/shared/snippet/cookbookbase/metadata_rb.erb +10 -0
- data/shared/snippet/examplefile/files_default_example_conf +34 -0
- data/shared/snippet/exampletemplate/templates_default_example_conf_erb +22 -0
- data/shared/snippet/recipes/recipes_default_rb.erb +9 -0
- data/shared/snippet/resourceprovider/providers_default_rb.erb +20 -0
- data/shared/snippet/resourceprovider/resources_default_rb.erb +9 -0
- data/shared/snippet/stylerubocop/_rubocop_yml.erb +27 -0
- data/shared/snippet/testkitchen/_kitchen_yml.erb +30 -0
- data/shared/snippet/testkitchen/libraries_kitchen_helper_rb +13 -0
- data/shared/snippet/testkitchen/test_integration_default_serverspec_recipes_default_spec_rb.erb +16 -0
- data/shared/snippet/testkitchen/test_integration_default_serverspec_spec_helper_rb.erb +7 -0
- metadata +42 -32
- data/.rubocop.yml +0 -27
- data/.travis.yml +0 -6
- data/Gemfile +0 -3
- data/Guardfile +0 -15
- data/Rakefile +0 -98
- data/features/generate.feature +0 -17
- data/features/support/env.rb +0 -15
- data/spec/lib/chef_gen/flavor_base_spec.rb +0 -167
- data/spec/lib/chef_gen/flavors_spec.rb +0 -132
- data/spec/lib/chef_gen/snippet/attributes_spec.rb +0 -40
- data/spec/lib/chef_gen/snippet/chef_spec_spec.rb +0 -40
- data/spec/lib/chef_gen/snippet/cookbook_base_spec.rb +0 -32
- data/spec/lib/chef_gen/snippet/example_file_spec.rb +0 -40
- data/spec/lib/chef_gen/snippet/example_template_spec.rb +0 -40
- data/spec/lib/chef_gen/snippet/git_init_spec.rb +0 -30
- data/spec/lib/chef_gen/snippet/recipes_spec.rb +0 -40
- data/spec/lib/chef_gen/snippet/resource_provider_spec.rb +0 -40
- data/spec/lib/chef_gen/snippet/standard_ignore_spec.rb +0 -35
- data/spec/lib/chef_gen/snippet/style_rubocop_spec.rb +0 -31
- data/spec/lib/chef_gen/snippet/test_kitchen_spec.rb +0 -44
- data/spec/spec_helper.rb +0 -64
- data/spec/support/fixtures/code_generator/metadata.rb +0 -2
- data/spec/support/fixtures/code_generator/recipes/cookbook.rb +0 -1
- data/spec/support/fixtures/code_generator_2/metadata.rb +0 -2
- data/spec/support/fixtures/code_generator_2/recipes/cookbook.rb +0 -3
- data/spec/support/fixtures/code_generator_2/templates/default/README_md.erb +0 -1
- data/spec/support/fixtures/lib/chef_gen/flavor/bar.rb +0 -21
- data/spec/support/fixtures/lib/chef_gen/flavor/baz.rb +0 -6
- data/spec/support/fixtures/lib/chef_gen/flavor/foo.rb +0 -9
@@ -9,10 +9,12 @@ module ChefGen
|
|
9
9
|
def snippet_gitinit(recipe)
|
10
10
|
c = generator_context
|
11
11
|
target_path = @target_path
|
12
|
+
# :nocov:
|
12
13
|
recipe.send(:execute, 'initialize git repo') do
|
13
14
|
command('git init .')
|
14
15
|
cwd target_path
|
15
16
|
end if c.have_git && !c.skip_git_init
|
17
|
+
# :nocov:
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
@@ -17,6 +17,21 @@ module ChefGen
|
|
17
17
|
def snippet_recipes_files(recipe)
|
18
18
|
@templates_if_missing << File.join('recipes', 'default.rb')
|
19
19
|
end
|
20
|
+
|
21
|
+
# copies snippet content
|
22
|
+
# @param path [String] the path to the temporary generator cookbook
|
23
|
+
# @return [void]
|
24
|
+
def content_recipes_files(path)
|
25
|
+
%w(recipes_default_rb.erb).each do |file|
|
26
|
+
copy_snippet_file(
|
27
|
+
File.join(
|
28
|
+
File.dirname(__FILE__), '..', '..', '..',
|
29
|
+
'shared', 'snippet', 'recipes', file
|
30
|
+
),
|
31
|
+
File.join(path, 'templates', 'default', file)
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
20
35
|
end
|
21
36
|
end
|
22
37
|
end
|
@@ -19,6 +19,24 @@ module ChefGen
|
|
19
19
|
@templates_if_missing << File.join('resources', 'default.rb')
|
20
20
|
@templates_if_missing << File.join('providers', 'default.rb')
|
21
21
|
end
|
22
|
+
|
23
|
+
# copies snippet content
|
24
|
+
# @param path [String] the path to the temporary generator cookbook
|
25
|
+
# @return [void]
|
26
|
+
def content_resourceprovider_files(path)
|
27
|
+
%w(
|
28
|
+
resources_default_rb.erb
|
29
|
+
providers_default_rb.erb
|
30
|
+
).each do |file|
|
31
|
+
copy_snippet_file(
|
32
|
+
File.join(
|
33
|
+
File.dirname(__FILE__), '..', '..', '..',
|
34
|
+
'shared', 'snippet', 'resourceprovider', file
|
35
|
+
),
|
36
|
+
File.join(path, 'templates', 'default', file)
|
37
|
+
)
|
38
|
+
end
|
39
|
+
end
|
22
40
|
end
|
23
41
|
end
|
24
42
|
end
|
@@ -3,94 +3,70 @@ module ChefGen
|
|
3
3
|
module Snippet
|
4
4
|
# populates the list of ignore patterns for chefignore and .gitignore
|
5
5
|
module StandardIgnore
|
6
|
-
# adds
|
6
|
+
# adds an array for chefignore patterns
|
7
|
+
attr_reader :chefignore_patterns
|
8
|
+
|
9
|
+
# adds an array for gitignore patterns
|
10
|
+
attr_reader :gitignore_patterns
|
11
|
+
|
12
|
+
# initializes the pattern arrays
|
13
|
+
def init_standardignore_instancevars
|
14
|
+
@chefignore_patterns = %w(
|
15
|
+
.DS_Store Icon? nohup.out ehthumbs.db Thumbs.db
|
16
|
+
.sasscache \#* .#* *~ *.sw[az] *.bak REVISION TAGS*
|
17
|
+
tmtags *_flymake.* *_flymake *.tmproj .project .settings
|
18
|
+
mkmf.log a.out *.o *.pyc *.so *.com *.class *.dll
|
19
|
+
*.exe */rdoc/ .watchr test/* features/* Procfile
|
20
|
+
.git */.git .gitignore .gitmodules .gitconfig .gitattributes
|
21
|
+
.svn */.bzr/* */.hg/*
|
22
|
+
)
|
23
|
+
@gitignore_patterns = %w(
|
24
|
+
Berksfile.lock *~ *# .#* \#*# .*.sw[az] *.un~
|
25
|
+
bin/* .bundle/*
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
# rubocop:disable Metrics/AbcSize
|
30
|
+
|
31
|
+
# declares ignore files
|
32
|
+
# @param recipe [Chef::Recipe] the recipe into which resources
|
33
|
+
# will be injected
|
34
|
+
# @return [void]
|
35
|
+
def snippet_standardignore_files(recipe)
|
36
|
+
add_chefignore_resource(recipe)
|
37
|
+
add_gitignore_resource(recipe)
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
# add the chefignore file resource, with content from the list
|
43
|
+
# of patterns in the instance var set to reasonable defaults
|
44
|
+
# and lazily evaluated
|
7
45
|
# @param recipe [Chef::Recipe] the recipe into which resources
|
8
46
|
# will be injected
|
9
47
|
# @return [void]
|
10
|
-
def
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
.sass-cache
|
18
|
-
\#*
|
19
|
-
.#*
|
20
|
-
*~
|
21
|
-
*.sw[a-z]
|
22
|
-
*.bak
|
23
|
-
REVISION
|
24
|
-
TAGS*
|
25
|
-
tmtags
|
26
|
-
*_flymake.*
|
27
|
-
*_flymake
|
28
|
-
*.tmproj
|
29
|
-
.project
|
30
|
-
.settings
|
31
|
-
mkmf.log
|
32
|
-
a.out
|
33
|
-
*.o
|
34
|
-
*.pyc
|
35
|
-
*.so
|
36
|
-
*.com
|
37
|
-
*.class
|
38
|
-
*.dll
|
39
|
-
*.exe
|
40
|
-
*/rdoc/
|
41
|
-
.watchr
|
42
|
-
.rspec
|
43
|
-
spec/*
|
44
|
-
spec/fixtures/*
|
45
|
-
test/*
|
46
|
-
features/*
|
47
|
-
Guardfile
|
48
|
-
Procfile
|
49
|
-
.git
|
50
|
-
*/.git
|
51
|
-
.gitignore
|
52
|
-
.gitmodules
|
53
|
-
.gitconfig
|
54
|
-
.gitattributes
|
55
|
-
.svn
|
56
|
-
*/.bzr/*
|
57
|
-
*/.hg/*
|
58
|
-
*/.svn/*
|
59
|
-
Berksfile
|
60
|
-
Berksfile.lock
|
61
|
-
cookbooks/*
|
62
|
-
tmp
|
63
|
-
CONTRIBUTING
|
64
|
-
Colanderfile
|
65
|
-
Strainerfile
|
66
|
-
.colander
|
67
|
-
.strainer
|
68
|
-
.vagrant
|
69
|
-
Vagrantfile
|
70
|
-
.travis.yml
|
71
|
-
END
|
48
|
+
def add_chefignore_resource(recipe)
|
49
|
+
patterns = @chefignore_patterns
|
50
|
+
# :nocov:
|
51
|
+
recipe.send(:file, File.join(@target_path, 'chefignore')) do
|
52
|
+
content lazy { patterns.sort.uniq.join("\n") + "\n" }
|
53
|
+
end
|
54
|
+
# :nocov:
|
72
55
|
end
|
73
56
|
|
74
|
-
#
|
57
|
+
# add the .gitignore file resource, with content from the list
|
58
|
+
# of patterns in the instance var set to reasonable defaults
|
59
|
+
# and lazily evaluated
|
75
60
|
# @param recipe [Chef::Recipe] the recipe into which resources
|
76
61
|
# will be injected
|
77
62
|
# @return [void]
|
78
|
-
def
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
\#*#
|
86
|
-
.*.sw[a-z]
|
87
|
-
*.un~
|
88
|
-
Gemfile.lock
|
89
|
-
bin/*
|
90
|
-
.bundle/*
|
91
|
-
.kitchen/
|
92
|
-
.kitchen.local.yml
|
93
|
-
END
|
63
|
+
def add_gitignore_resource(recipe)
|
64
|
+
patterns = @gitignore_patterns
|
65
|
+
# :nocov:
|
66
|
+
recipe.send(:file, File.join(@target_path, '.gitignore')) do
|
67
|
+
content lazy { patterns.sort.uniq.join("\n") + "\n" }
|
68
|
+
end
|
69
|
+
# :nocov:
|
94
70
|
end
|
95
71
|
end
|
96
72
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module ChefGen
|
2
|
+
module Snippet
|
3
|
+
# sets up style testing using Foodcritic
|
4
|
+
module StyleFoodcritic
|
5
|
+
# adds foodcritic gems to the Gemfile
|
6
|
+
# @param recipe [Chef::Recipe] the recipe into which resources
|
7
|
+
# will be injected
|
8
|
+
# @return [void]
|
9
|
+
def snippet_stylefoodcritic_gems(recipe)
|
10
|
+
return unless respond_to?(:cookbook_gems)
|
11
|
+
cookbook_gems['foodcritic'] = '~> 4.0'
|
12
|
+
cookbook_gems['guard-foodcritic'] = '~> 1.1'
|
13
|
+
end
|
14
|
+
|
15
|
+
# adds foodcritic rake tasks to the Rakefile
|
16
|
+
# @param recipe [Chef::Recipe] the recipe into which resources
|
17
|
+
# will be injected
|
18
|
+
# @return [void]
|
19
|
+
def snippet_foodcritic_raketasks(recipe)
|
20
|
+
return unless respond_to?(:rake_tasks)
|
21
|
+
rake_tasks['foodcritic'] = <<'END'
|
22
|
+
require 'foodcritic'
|
23
|
+
require 'foodcritic/rake_task'
|
24
|
+
|
25
|
+
FoodCritic::Rake::LintTask.new(:foodcritic)
|
26
|
+
task style: :foodcritic
|
27
|
+
END
|
28
|
+
end
|
29
|
+
|
30
|
+
# adds foodcritic sets to the Guardfile
|
31
|
+
# @param recipe [Chef::Recipe] the recipe into which resources
|
32
|
+
# will be injected
|
33
|
+
# @return [void]
|
34
|
+
def snippet_foodcritic_guardsets(recipe)
|
35
|
+
return unless respond_to?(:guard_sets)
|
36
|
+
guard_sets['foodcritic'] = <<'END'
|
37
|
+
guard :foodcritic,
|
38
|
+
cookbook_paths: '.',
|
39
|
+
cli: '-f any -X spec -X test -X features' do
|
40
|
+
watch(%r{^attributes/.+\.rb$})
|
41
|
+
watch(%r{^resources/.+\.rb$})
|
42
|
+
watch(%r{^providers/.+\.rb$})
|
43
|
+
watch(%r{^libraries/.+\.rb$})
|
44
|
+
watch(%r{^recipes/.+\.rb$})
|
45
|
+
watch(%r{^metadata\.rb$})
|
46
|
+
end
|
47
|
+
END
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -9,6 +9,86 @@ module ChefGen
|
|
9
9
|
def snippet_stylerubocop_config(recipe)
|
10
10
|
@templates_if_missing << '.rubocop.yml'
|
11
11
|
end
|
12
|
+
|
13
|
+
# adds rubocop gems to the Gemfile
|
14
|
+
# @param recipe [Chef::Recipe] the recipe into which resources
|
15
|
+
# will be injected
|
16
|
+
# @return [void]
|
17
|
+
def snippet_stylerubocop_gems(recipe)
|
18
|
+
return unless respond_to?(:cookbook_gems)
|
19
|
+
cookbook_gems['rubocop'] = '~> 0.31'
|
20
|
+
cookbook_gems['guard-rubocop'] = '~> 1.1'
|
21
|
+
end
|
22
|
+
|
23
|
+
# copies snippet content
|
24
|
+
# @param path [String] the path to the temporary generator cookbook
|
25
|
+
# @return [void]
|
26
|
+
def content_stylerubocop_files(path)
|
27
|
+
%w(_rubocop_yml.erb).each do |file|
|
28
|
+
copy_snippet_file(
|
29
|
+
File.join(
|
30
|
+
File.dirname(__FILE__), '..', '..', '..',
|
31
|
+
'shared', 'snippet', 'stylerubocop', file
|
32
|
+
),
|
33
|
+
File.join(path, 'templates', 'default', file)
|
34
|
+
)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# rubocop:disable Metrics/MethodLength
|
39
|
+
|
40
|
+
# adds rubocop rake tasks to the Rakefile
|
41
|
+
# @param recipe [Chef::Recipe] the recipe into which resources
|
42
|
+
# will be injected
|
43
|
+
# @return [void]
|
44
|
+
def snippet_rubocop_raketasks(recipe)
|
45
|
+
return unless respond_to?(:rake_tasks)
|
46
|
+
rake_tasks['rubocop'] = <<'END'
|
47
|
+
require 'rubocop/rake_task'
|
48
|
+
|
49
|
+
RuboCop::RakeTask.new(:rubocop) do |t|
|
50
|
+
t.formatters = ['progress']
|
51
|
+
t.options = ['-D']
|
52
|
+
t.patterns = %w(
|
53
|
+
attributes/*.rb
|
54
|
+
recipes/*.rb
|
55
|
+
libraries/**/*.rb
|
56
|
+
resources/*.rb
|
57
|
+
providers/*.rb
|
58
|
+
spec/**/*.rb
|
59
|
+
test/**/*.rb
|
60
|
+
./metadata.rb
|
61
|
+
./Berksfile
|
62
|
+
./Gemfile
|
63
|
+
./Rakefile
|
64
|
+
)
|
65
|
+
end
|
66
|
+
task style: :rubocop
|
67
|
+
END
|
68
|
+
end
|
69
|
+
|
70
|
+
# adds rubocop sets to the Guardfile
|
71
|
+
# @param recipe [Chef::Recipe] the recipe into which resources
|
72
|
+
# will be injected
|
73
|
+
# @return [void]
|
74
|
+
def snippet_rubocop_guardsets(recipe)
|
75
|
+
return unless respond_to?(:guard_sets)
|
76
|
+
guard_sets['rubocop'] = <<'END'
|
77
|
+
guard :rubocop, all_on_start: true, cli: ['-f', 'p', '-D'] do
|
78
|
+
watch(%r{^attributes/.+\.rb$})
|
79
|
+
watch(%r{^recipes/.+\.rb$})
|
80
|
+
watch(%r{^libraries/.+\.rb$})
|
81
|
+
watch(%r{^resources/.+\.rb$})
|
82
|
+
watch(%r{^providers/.+\.rb$})
|
83
|
+
watch(%r{^spec/.+\.rb$})
|
84
|
+
watch(%r{^test/.+\.rb$})
|
85
|
+
watch(%r{^metadata\.rb$})
|
86
|
+
watch(%r{^Berksfile$})
|
87
|
+
watch(%r{^Gemfile$})
|
88
|
+
watch(%r{^Rakefile$})
|
89
|
+
end
|
90
|
+
END
|
91
|
+
end
|
12
92
|
end
|
13
93
|
end
|
14
94
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module ChefGen
|
2
|
+
module Snippet
|
3
|
+
# sets up style testing using Tailor
|
4
|
+
module StyleTailor
|
5
|
+
# adds tailor gems to the Gemfile
|
6
|
+
# @param recipe [Chef::Recipe] the recipe into which resources
|
7
|
+
# will be injected
|
8
|
+
# @return [void]
|
9
|
+
def snippet_styletailor_gems(recipe)
|
10
|
+
return unless respond_to?(:cookbook_gems)
|
11
|
+
cookbook_gems['tailor'] = '~> 1.4'
|
12
|
+
cookbook_gems['guard-rake'] = '~> 0.0'
|
13
|
+
end
|
14
|
+
|
15
|
+
# rubocop:disable Metrics/MethodLength
|
16
|
+
|
17
|
+
# adds tailor rake tasks to the Rakefile
|
18
|
+
# @param recipe [Chef::Recipe] the recipe into which resources
|
19
|
+
# will be injected
|
20
|
+
# @return [void]
|
21
|
+
def snippet_tailor_raketasks(recipe)
|
22
|
+
return unless respond_to?(:rake_tasks)
|
23
|
+
rake_tasks['tailor'] = <<'END'
|
24
|
+
require 'tailor/rake_task'
|
25
|
+
Tailor::RakeTask.new do |t|
|
26
|
+
{
|
27
|
+
spec: 'spec/recipes/*_spec.rb',
|
28
|
+
spec_helper: 'spec/spec_helper.rb',
|
29
|
+
attributes: 'attributes/*.rb',
|
30
|
+
resources: 'resources/*.rb',
|
31
|
+
providers: 'providers/*.rb',
|
32
|
+
libraries: 'libraries/**/*.rb',
|
33
|
+
recipes: 'recipes/*.rb',
|
34
|
+
metadata: 'metadata.rb'
|
35
|
+
}.each do |name, glob|
|
36
|
+
t.file_set glob, name do |s|
|
37
|
+
s.max_line_length 1000
|
38
|
+
s.max_code_lines_in_method 1000
|
39
|
+
s.max_code_lines_in_class 1000
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
task style: :tailor
|
44
|
+
END
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -1,15 +1,8 @@
|
|
1
|
+
# rubocop:disable Metrics/MethodLength
|
1
2
|
module ChefGen
|
2
3
|
module Snippet
|
3
4
|
# creates a framework for Test Kitchen integration testing
|
4
5
|
module TestKitchen
|
5
|
-
# declares the Test Kitchen config
|
6
|
-
# @param recipe [Chef::Recipe] the recipe into which resources
|
7
|
-
# will be injected
|
8
|
-
# @return [void]
|
9
|
-
def snippet_testkitchen_config(recipe)
|
10
|
-
@templates_if_missing << '.kitchen.yml'
|
11
|
-
end
|
12
|
-
|
13
6
|
# declares directories
|
14
7
|
# @param recipe [Chef::Recipe] the recipe into which resources
|
15
8
|
# will be injected
|
@@ -26,24 +19,86 @@ module ChefGen
|
|
26
19
|
)
|
27
20
|
end
|
28
21
|
|
29
|
-
# declares the Test Kitchen
|
22
|
+
# declares the Test Kitchen config
|
30
23
|
# @param recipe [Chef::Recipe] the recipe into which resources
|
31
24
|
# will be injected
|
32
25
|
# @return [void]
|
33
|
-
def
|
26
|
+
def snippet_testkitchen_files(recipe)
|
27
|
+
@templates_if_missing << '.kitchen.yml'
|
34
28
|
@templates_if_missing << File.join(
|
35
29
|
'test', 'integration', 'default', 'serverspec', 'spec_helper.rb'
|
36
30
|
)
|
31
|
+
@templates_if_missing << File.join(
|
32
|
+
'test', 'integration', 'default', 'serverspec',
|
33
|
+
'recipes', 'default_spec.rb'
|
34
|
+
)
|
37
35
|
end
|
38
36
|
|
39
|
-
#
|
37
|
+
# adds testkitchen to the git and chefignore patterns
|
40
38
|
# @param recipe [Chef::Recipe] the recipe into which resources
|
41
39
|
# will be injected
|
42
40
|
# @return [void]
|
43
|
-
def
|
44
|
-
|
45
|
-
|
46
|
-
|
41
|
+
def snippet_testkitchen_ignore(recipe)
|
42
|
+
%w(
|
43
|
+
.vagrant
|
44
|
+
.kitchen/
|
45
|
+
.kitchen.local.yml
|
46
|
+
).each do |e|
|
47
|
+
gitignore_patterns << e if respond_to?(:gitignore_patterns)
|
48
|
+
chefignore_patterns << e if respond_to?(:chefignore_patterns)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# adds testkitchen gems to the Gemfile
|
53
|
+
# @param recipe [Chef::Recipe] the recipe into which resources
|
54
|
+
# will be injected
|
55
|
+
# @return [void]
|
56
|
+
def snippet_testkitchen_gems(recipe)
|
57
|
+
return unless respond_to?(:cookbook_gems)
|
58
|
+
cookbook_gems['test-kitchen'] = '~> 1.4'
|
59
|
+
cookbook_gems['kitchen-vagrant'] = '~> 0.16'
|
60
|
+
end
|
61
|
+
|
62
|
+
# adds testkitchen rake tasks to the Rakefile
|
63
|
+
# @param recipe [Chef::Recipe] the recipe into which resources
|
64
|
+
# will be injected
|
65
|
+
# @return [void]
|
66
|
+
def snippet_testkitchen_raketasks(recipe)
|
67
|
+
return unless respond_to?(:rake_tasks)
|
68
|
+
rake_tasks['testkitchen'] = <<'END'
|
69
|
+
require 'kitchen/rake_tasks'
|
70
|
+
begin
|
71
|
+
Kitchen::RakeTasks.new
|
72
|
+
rescue LoadError
|
73
|
+
puts 'test-kitchen initialization failed; disabling kitchen tasks'
|
74
|
+
end
|
75
|
+
task integration: 'kitchen:all'
|
76
|
+
END
|
77
|
+
end
|
78
|
+
|
79
|
+
# copies snippet content
|
80
|
+
# @param path [String] the path to the temporary generator cookbook
|
81
|
+
# @return [void]
|
82
|
+
def content_testkitchen_files(path)
|
83
|
+
%w(
|
84
|
+
_kitchen_yml.erb
|
85
|
+
test_integration_default_serverspec_spec_helper_rb.erb
|
86
|
+
test_integration_default_serverspec_recipes_default_spec_rb.erb
|
87
|
+
).each do |file|
|
88
|
+
copy_snippet_file(
|
89
|
+
File.join(
|
90
|
+
File.dirname(__FILE__), '..', '..', '..',
|
91
|
+
'shared', 'snippet', 'testkitchen', file
|
92
|
+
),
|
93
|
+
File.join(path, 'templates', 'default', file)
|
94
|
+
)
|
95
|
+
end
|
96
|
+
copy_snippet_file(
|
97
|
+
File.join(
|
98
|
+
File.dirname(__FILE__), '..', '..', '..',
|
99
|
+
'shared', 'snippet', 'testkitchen', 'libraries_kitchen_helper_rb'
|
100
|
+
),
|
101
|
+
File.join(path, 'libraries', 'kitchen_helper.rb')
|
47
102
|
)
|
48
103
|
end
|
49
104
|
end
|