chef-gen-flavor-example 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +2 -0
- data/.rubocop.yml +13 -0
- data/.travis.yml +6 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +244 -0
- data/Guardfile +15 -0
- data/History.md +9 -0
- data/LICENSE +15 -0
- data/Manifest.txt +36 -0
- data/README.md +149 -0
- data/Rakefile +84 -0
- data/chef-gen-flavor-example.gemspec +72 -0
- data/code_generator/files/default/files_default_example_conf +34 -0
- data/code_generator/files/default/templates_default_example_conf_erb +22 -0
- data/code_generator/libraries/kitchen_helper.rb +13 -0
- data/code_generator/metadata.rb +2 -0
- data/code_generator/recipes/cookbook.rb +11 -0
- data/code_generator/templates/default/Berksfile.erb +3 -0
- data/code_generator/templates/default/CHANGELOG_md.erb +5 -0
- data/code_generator/templates/default/Gemfile.erb +25 -0
- data/code_generator/templates/default/Guardfile.erb +41 -0
- data/code_generator/templates/default/README_md.erb +92 -0
- data/code_generator/templates/default/Rakefile.erb +45 -0
- data/code_generator/templates/default/_kitchen_yml.erb +28 -0
- data/code_generator/templates/default/_rspec.erb +2 -0
- data/code_generator/templates/default/_rubocop_yml.erb +17 -0
- data/code_generator/templates/default/attributes_default_rb.erb +8 -0
- data/code_generator/templates/default/metadata_rb.erb +10 -0
- data/code_generator/templates/default/recipes_default_rb.erb +9 -0
- data/code_generator/templates/default/spec_recipes_default_spec_rb.erb +7 -0
- data/code_generator/templates/default/spec_spec_helper_rb.erb +92 -0
- data/code_generator/templates/default/test_integration_default_serverspec_recipes_default_spec_rb.erb +16 -0
- data/code_generator/templates/default/test_integration_default_serverspec_spec_helper_rb.erb +7 -0
- data/lib/chef_gen/flavor/example.rb +32 -0
- data/spec/lib/chef_gen/flavor/example_spec.rb +88 -0
- data/spec/spec_helper.rb +23 -0
- metadata +287 -0
data/Rakefile
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'chef_gen/flavor/example'
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'hoe'
|
5
|
+
Hoe.plugin :gemspec
|
6
|
+
Hoe.plugins.delete :test
|
7
|
+
Hoe.spec 'chef-gen-flavor-example' do |s|
|
8
|
+
s.version = ChefGen::Flavor::Example::VERSION
|
9
|
+
developer 'James FitzGibbon', 'james.i.fitzgibbon@nordstrom.com'
|
10
|
+
license 'apache2'
|
11
|
+
extra_deps << ['chef-gen-flavors', '~> 0.3']
|
12
|
+
extra_dev_deps << ['chef-dk', '~> 0.5']
|
13
|
+
extra_dev_deps << ['hoe', '~> 3.13']
|
14
|
+
extra_dev_deps << ['hoe-gemspec', '~> 1.0']
|
15
|
+
extra_dev_deps << ['rake', '~> 10.3']
|
16
|
+
extra_dev_deps << ['rspec', '~> 3.1']
|
17
|
+
extra_dev_deps << ['guard', '~> 2.12']
|
18
|
+
extra_dev_deps << ['guard-rspec', '~> 4.2']
|
19
|
+
extra_dev_deps << ['guard-rake', '~> 0.0']
|
20
|
+
extra_dev_deps << ['guard-rubocop', '~> 1.2']
|
21
|
+
extra_dev_deps << ['simplecov', '~> 0.9']
|
22
|
+
extra_dev_deps << ['simplecov-console', '~> 0.2']
|
23
|
+
extra_dev_deps << ['yard', '~> 0.8']
|
24
|
+
end
|
25
|
+
# re-generate our gemspec before packaging
|
26
|
+
task package: 'gem:spec'
|
27
|
+
rescue LoadError
|
28
|
+
puts 'hoe not available; disabling tasks'
|
29
|
+
end
|
30
|
+
|
31
|
+
# Style Tests
|
32
|
+
begin
|
33
|
+
require 'rubocop/rake_task'
|
34
|
+
RuboCop::RakeTask.new do |t|
|
35
|
+
t.formatters = ['progress']
|
36
|
+
t.options = ['-D']
|
37
|
+
t.patterns = %w(
|
38
|
+
lib/**/*.rb
|
39
|
+
spec/**/*.rb
|
40
|
+
./Rakefile
|
41
|
+
)
|
42
|
+
end
|
43
|
+
desc 'Run Style Tests'
|
44
|
+
task style: [:rubocop]
|
45
|
+
rescue LoadError
|
46
|
+
puts 'rubocop not available; disabling tasks'
|
47
|
+
end
|
48
|
+
|
49
|
+
# Unit Tests
|
50
|
+
begin
|
51
|
+
require 'rspec/core/rake_task'
|
52
|
+
RSpec::Core::RakeTask.new
|
53
|
+
|
54
|
+
# Coverage
|
55
|
+
desc 'Generate unit test coverage report'
|
56
|
+
task :coverage do
|
57
|
+
ENV['COVERAGE'] = 'true'
|
58
|
+
Rake::Task[:test].invoke
|
59
|
+
end
|
60
|
+
rescue LoadError
|
61
|
+
puts 'rspec not available; disabling tasks'
|
62
|
+
# create a no-op task so that :default works
|
63
|
+
task :test
|
64
|
+
end
|
65
|
+
|
66
|
+
# Documentation
|
67
|
+
begin
|
68
|
+
require 'yard'
|
69
|
+
require 'yard/rake/yardoc_task'
|
70
|
+
YARD::Rake::YardocTask.new(:doc) do |t|
|
71
|
+
t.options = ['-m', 'markdown', '--private']
|
72
|
+
t.stats_options = ['--list-undoc']
|
73
|
+
end
|
74
|
+
rescue LoadError
|
75
|
+
puts 'yard not available; disabling tasks'
|
76
|
+
end
|
77
|
+
|
78
|
+
# test is an alias for spec
|
79
|
+
desc 'runs unit tests'
|
80
|
+
task test: [:spec]
|
81
|
+
|
82
|
+
# default is to test everything
|
83
|
+
desc 'runs all tests'
|
84
|
+
task default: :test
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# stub: chef-gen-flavor-example 0.2.0.20150514061744 ruby lib
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "chef-gen-flavor-example"
|
6
|
+
s.version = "0.2.0.20150514061744"
|
7
|
+
|
8
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
|
+
s.require_paths = ["lib"]
|
10
|
+
s.authors = ["James FitzGibbon"]
|
11
|
+
s.date = "2015-05-14"
|
12
|
+
s.description = "An example plugin for [chef-gen-flavors](https://rubygems.org/gems/chef-gen-flavors).\n\nThis plugin makes use of most of the snippets available, and is meant as a\nreference implementation than for actual use. It demonstrates how to create\na template plugin with tests and serve as a good example of how to get\nstarted writing your own templates for distribution."
|
13
|
+
s.email = ["james.i.fitzgibbon@nordstrom.com"]
|
14
|
+
s.extra_rdoc_files = ["History.md", "Manifest.txt", "README.md"]
|
15
|
+
s.files = [".rspec", ".rubocop.yml", ".travis.yml", "Gemfile", "Gemfile.lock", "Guardfile", "History.md", "LICENSE", "Manifest.txt", "README.md", "Rakefile", "chef-gen-flavor-example.gemspec", "code_generator/files/default/files_default_example_conf", "code_generator/files/default/templates_default_example_conf_erb", "code_generator/libraries/kitchen_helper.rb", "code_generator/metadata.rb", "code_generator/recipes/cookbook.rb", "code_generator/templates/default/Berksfile.erb", "code_generator/templates/default/CHANGELOG_md.erb", "code_generator/templates/default/Gemfile.erb", "code_generator/templates/default/Guardfile.erb", "code_generator/templates/default/README_md.erb", "code_generator/templates/default/Rakefile.erb", "code_generator/templates/default/_kitchen_yml.erb", "code_generator/templates/default/_rspec.erb", "code_generator/templates/default/_rubocop_yml.erb", "code_generator/templates/default/attributes_default_rb.erb", "code_generator/templates/default/metadata_rb.erb", "code_generator/templates/default/recipes_default_rb.erb", "code_generator/templates/default/spec_recipes_default_spec_rb.erb", "code_generator/templates/default/spec_spec_helper_rb.erb", "code_generator/templates/default/test_integration_default_serverspec_recipes_default_spec_rb.erb", "code_generator/templates/default/test_integration_default_serverspec_spec_helper_rb.erb", "lib/chef_gen/flavor/example.rb", "spec/lib/chef_gen/flavor/example_spec.rb", "spec/spec_helper.rb"]
|
16
|
+
s.homepage = "https://github.com/Nordstrom/chef-gen-flavor-example"
|
17
|
+
s.licenses = ["apache2"]
|
18
|
+
s.rdoc_options = ["--main", "README.md"]
|
19
|
+
s.rubygems_version = "2.4.4"
|
20
|
+
s.summary = "An example plugin for [chef-gen-flavors](https://rubygems.org/gems/chef-gen-flavors)"
|
21
|
+
|
22
|
+
if s.respond_to? :specification_version then
|
23
|
+
s.specification_version = 4
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
|
+
s.add_runtime_dependency(%q<chef-gen-flavors>, ["~> 0.3"])
|
27
|
+
s.add_development_dependency(%q<rdoc>, ["~> 4.0"])
|
28
|
+
s.add_development_dependency(%q<chef-dk>, ["~> 0.5"])
|
29
|
+
s.add_development_dependency(%q<hoe>, ["~> 3.13"])
|
30
|
+
s.add_development_dependency(%q<hoe-gemspec>, ["~> 1.0"])
|
31
|
+
s.add_development_dependency(%q<rake>, ["~> 10.3"])
|
32
|
+
s.add_development_dependency(%q<rspec>, ["~> 3.1"])
|
33
|
+
s.add_development_dependency(%q<guard>, ["~> 2.12"])
|
34
|
+
s.add_development_dependency(%q<guard-rspec>, ["~> 4.2"])
|
35
|
+
s.add_development_dependency(%q<guard-rake>, ["~> 0.0"])
|
36
|
+
s.add_development_dependency(%q<guard-rubocop>, ["~> 1.2"])
|
37
|
+
s.add_development_dependency(%q<simplecov>, ["~> 0.9"])
|
38
|
+
s.add_development_dependency(%q<simplecov-console>, ["~> 0.2"])
|
39
|
+
s.add_development_dependency(%q<yard>, ["~> 0.8"])
|
40
|
+
else
|
41
|
+
s.add_dependency(%q<chef-gen-flavors>, ["~> 0.3"])
|
42
|
+
s.add_dependency(%q<rdoc>, ["~> 4.0"])
|
43
|
+
s.add_dependency(%q<chef-dk>, ["~> 0.5"])
|
44
|
+
s.add_dependency(%q<hoe>, ["~> 3.13"])
|
45
|
+
s.add_dependency(%q<hoe-gemspec>, ["~> 1.0"])
|
46
|
+
s.add_dependency(%q<rake>, ["~> 10.3"])
|
47
|
+
s.add_dependency(%q<rspec>, ["~> 3.1"])
|
48
|
+
s.add_dependency(%q<guard>, ["~> 2.12"])
|
49
|
+
s.add_dependency(%q<guard-rspec>, ["~> 4.2"])
|
50
|
+
s.add_dependency(%q<guard-rake>, ["~> 0.0"])
|
51
|
+
s.add_dependency(%q<guard-rubocop>, ["~> 1.2"])
|
52
|
+
s.add_dependency(%q<simplecov>, ["~> 0.9"])
|
53
|
+
s.add_dependency(%q<simplecov-console>, ["~> 0.2"])
|
54
|
+
s.add_dependency(%q<yard>, ["~> 0.8"])
|
55
|
+
end
|
56
|
+
else
|
57
|
+
s.add_dependency(%q<chef-gen-flavors>, ["~> 0.3"])
|
58
|
+
s.add_dependency(%q<rdoc>, ["~> 4.0"])
|
59
|
+
s.add_dependency(%q<chef-dk>, ["~> 0.5"])
|
60
|
+
s.add_dependency(%q<hoe>, ["~> 3.13"])
|
61
|
+
s.add_dependency(%q<hoe-gemspec>, ["~> 1.0"])
|
62
|
+
s.add_dependency(%q<rake>, ["~> 10.3"])
|
63
|
+
s.add_dependency(%q<rspec>, ["~> 3.1"])
|
64
|
+
s.add_dependency(%q<guard>, ["~> 2.12"])
|
65
|
+
s.add_dependency(%q<guard-rspec>, ["~> 4.2"])
|
66
|
+
s.add_dependency(%q<guard-rake>, ["~> 0.0"])
|
67
|
+
s.add_dependency(%q<guard-rubocop>, ["~> 1.2"])
|
68
|
+
s.add_dependency(%q<simplecov>, ["~> 0.9"])
|
69
|
+
s.add_dependency(%q<simplecov-console>, ["~> 0.2"])
|
70
|
+
s.add_dependency(%q<yard>, ["~> 0.8"])
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# this is an example of a Chef cookbook file. It is
|
2
|
+
# copied intact when referenced by the cookbook_file
|
3
|
+
# resource.
|
4
|
+
|
5
|
+
[today_2014_09_17]
|
6
|
+
variable = value
|
7
|
+
|
8
|
+
[section_two]
|
9
|
+
variable_1=value_1
|
10
|
+
variable_2=value_2
|
11
|
+
variable_3=value_3
|
12
|
+
variable_4=value_4
|
13
|
+
variable_5=value_5
|
14
|
+
|
15
|
+
[section_three]
|
16
|
+
variable_1=value_1
|
17
|
+
variable_2=value_2
|
18
|
+
variable_3=value_3
|
19
|
+
variable_4=value_4
|
20
|
+
variable_5=value_5
|
21
|
+
|
22
|
+
[section_four]
|
23
|
+
variable_1=value_1
|
24
|
+
variable_2=value_2
|
25
|
+
variable_3=value_3
|
26
|
+
variable_4=value_4
|
27
|
+
variable_5=value_5
|
28
|
+
|
29
|
+
[section_five]
|
30
|
+
variable_1=value_1
|
31
|
+
variable_2=value_2
|
32
|
+
variable_3=value_3
|
33
|
+
variable_4=value_4
|
34
|
+
variable_5=value_5
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# this is an example of a Chef template. It is a simple
|
2
|
+
# INI-style file. The first section name is dynamically
|
3
|
+
# generated to be the current date in YYYY_MM_DD format
|
4
|
+
# and the second through fifth sections are generated in
|
5
|
+
# an 'each' loop.
|
6
|
+
#
|
7
|
+
# note that ending an ERB tag with -% instead of just %,
|
8
|
+
# that line doesn't produce an empty line in the output.
|
9
|
+
# Use this syntax on lines that are pure logic (like the
|
10
|
+
# require line and start and end of the loop) and contain
|
11
|
+
# no actual output
|
12
|
+
|
13
|
+
<% require 'date' -%>
|
14
|
+
[today_<%= DateTime.now.strftime('%Y_%M_%D') %>]
|
15
|
+
variable = value
|
16
|
+
|
17
|
+
<% %w(two three four five).each do |section_name| -%>
|
18
|
+
[<%= section_name %>]
|
19
|
+
<% 5.times do |i| -%>
|
20
|
+
variable_<%= i %>=value_<%= i %>
|
21
|
+
<% end -%>
|
22
|
+
<% end -%>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# produces ERB to conditionally set proxy vars in kitchen at
|
2
|
+
# runtime. This can't go directly in the template because if
|
3
|
+
# it does it gets evaluated at generation time in the context
|
4
|
+
# of ChefDK
|
5
|
+
def kitchen_proxy_vars(indentspaces)
|
6
|
+
<<END
|
7
|
+
<% %w(http_proxy https_proxy no_proxy).each do |envvar| %>
|
8
|
+
<% if ENV.key?(envvar) %>
|
9
|
+
#{' ' * indentspaces}<%= envvar %>: '<%= ENV[envvar] %>'
|
10
|
+
<% end %>
|
11
|
+
<% end %>
|
12
|
+
END
|
13
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
template = ChefGen::Flavor::Example.new(self)
|
2
|
+
template.next_steps = <<END
|
3
|
+
|
4
|
+
|
5
|
+
Now cd into the generated cookbook directory and run
|
6
|
+
'bundle' to install Ruby gems needed for local testing and
|
7
|
+
'bundle exec rake -T' to see which testing tasks you can run.
|
8
|
+
|
9
|
+
You are now ready to begin writing your first recipe.
|
10
|
+
END
|
11
|
+
template.generate
|
@@ -0,0 +1,25 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
group :development do
|
4
|
+
gem 'rake', '~> 10.3'
|
5
|
+
gem 'pry'
|
6
|
+
gem 'pry-byebug'
|
7
|
+
gem 'pry-rescue', '~> 1.3'
|
8
|
+
gem 'pry-stack_explorer', '~> 0.4'
|
9
|
+
end
|
10
|
+
|
11
|
+
group :test do
|
12
|
+
gem 'foodcritic', '~> 4.0'
|
13
|
+
gem 'chefspec', '~> 4.1'
|
14
|
+
gem 'ci_reporter_rspec', '~> 1.0'
|
15
|
+
gem 'test-kitchen', '~> 1.4'
|
16
|
+
gem 'kitchen-vagrant', '~> 0.16'
|
17
|
+
gem 'berkshelf', '~> 3.2'
|
18
|
+
# pin to 2.8 series until guard-foodcritic has been updated for v2 API
|
19
|
+
gem 'guard', '~> 2.8.2'
|
20
|
+
# pin to 4.3 series until guard-foodcritic has been updated for v2 API
|
21
|
+
gem 'guard-rspec', '~> 4.3.1'
|
22
|
+
gem 'guard-foodcritic', '~> 1.0'
|
23
|
+
gem 'rubocop', '~> 0.30.0'
|
24
|
+
gem 'guard-rubocop', '~> 1.1'
|
25
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
notification :terminal_title
|
2
|
+
|
3
|
+
# prevent dropping into pry when nothing is happening
|
4
|
+
interactor :off
|
5
|
+
|
6
|
+
# automatically runs Foodcritic
|
7
|
+
guard :foodcritic, cookbook_paths: '.', cli: '-f any -X spec -X test -X features' do
|
8
|
+
watch(%r{^attributes/.+\.rb$})
|
9
|
+
watch(%r{^resources/.+\.rb$})
|
10
|
+
watch(%r{^providers/.+\.rb$})
|
11
|
+
watch(%r{^libraries/.+\.rb$})
|
12
|
+
watch(%r{^recipes/.+\.rb$})
|
13
|
+
watch(%r{^metadata\.rb$})
|
14
|
+
end
|
15
|
+
|
16
|
+
# automatically runs Rubocop
|
17
|
+
guard :rubocop, all_on_start: true, cli: ['-f', 'p', '-D'] do
|
18
|
+
watch(%r{^attributes/.+\.rb$})
|
19
|
+
watch(%r{^recipes/.+\.rb$})
|
20
|
+
watch(%r{^libraries/.+\.rb$})
|
21
|
+
watch(%r{^resources/.+\.rb$})
|
22
|
+
watch(%r{^providers/.+\.rb$})
|
23
|
+
watch(%r{^spec/.+\.rb$})
|
24
|
+
watch(%r{^test/.+\.rb$})
|
25
|
+
watch(%r{^metadata\.rb$})
|
26
|
+
watch(%r{^Berksfile$})
|
27
|
+
watch(%r{^Gemfile$})
|
28
|
+
watch(%r{^Rakefile$})
|
29
|
+
end
|
30
|
+
|
31
|
+
# automatically runs ChefSpec tests
|
32
|
+
rspec_command = ENV.key?('DISABLE_PRY_RESCUE') ? 'rspec' : 'rescue rspec'
|
33
|
+
guard :rspec, all_on_start: true, cmd: "bundle exec #{rspec_command}" do
|
34
|
+
watch(%r{^spec/recipes/.+_spec\.rb$})
|
35
|
+
watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
|
36
|
+
watch(%r{^attributes/.+\.rb$}) { 'spec' }
|
37
|
+
watch(%r{^resources/.+\.rb$}) { 'spec' }
|
38
|
+
watch(%r{^providers/.+\.rb$}) { 'spec' }
|
39
|
+
watch(%r{^libraries/.+\.rb$}) { 'spec' }
|
40
|
+
watch(%r{^recipes/(.+)\.rb$}) { |m| "spec/recipes/#{m[1]}_spec.rb" }
|
41
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# <%= cookbook_name %>
|
2
|
+
|
3
|
+
## Description
|
4
|
+
|
5
|
+
...
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
Add 'recipe[<%= cookbook_name %>::default]' to your node's run-list.
|
10
|
+
|
11
|
+
## Recipes
|
12
|
+
|
13
|
+
### default
|
14
|
+
|
15
|
+
The default recipe ...
|
16
|
+
|
17
|
+
## Attributes
|
18
|
+
|
19
|
+
The attributes defined by this recipe are organized under the
|
20
|
+
`node['<%= cookbook_name %>']` namespace.
|
21
|
+
|
22
|
+
Attribute | Description | Type | Default
|
23
|
+
----------|-------------|--------|--------
|
24
|
+
... | ... | String | ...
|
25
|
+
|
26
|
+
## Development
|
27
|
+
|
28
|
+
The first time you check out this cookbook, run
|
29
|
+
|
30
|
+
bundle --binstubs
|
31
|
+
|
32
|
+
to download and install the development tools.
|
33
|
+
|
34
|
+
## Testing
|
35
|
+
|
36
|
+
Three forms of cookbook testing are available:
|
37
|
+
|
38
|
+
### Style Checks
|
39
|
+
|
40
|
+
bin/rake style
|
41
|
+
|
42
|
+
Will run foodcritic (cookbook style) and tailor (ruby style/syntax)
|
43
|
+
checks. These tests must pass before the cookbook can progress
|
44
|
+
through the CI pipeline.
|
45
|
+
|
46
|
+
### Unit Tests
|
47
|
+
|
48
|
+
bin/rake spec
|
49
|
+
|
50
|
+
Will run ChefSpec tests. It is a good idea to ensure that these
|
51
|
+
tests pass before committing changes to git.
|
52
|
+
|
53
|
+
#### Unit Test Coverage
|
54
|
+
|
55
|
+
bin/rake coverage
|
56
|
+
|
57
|
+
Will run the ChefSpec tests and report on test coverage. It is a
|
58
|
+
good idea to make sure that every Chef resource you declare is covered
|
59
|
+
by a unit test.
|
60
|
+
|
61
|
+
#### Automated Testing with Guard
|
62
|
+
|
63
|
+
bin/guard
|
64
|
+
|
65
|
+
Will run foodcritic, tailor, rubocop (if enabled) and chefspec tests
|
66
|
+
automatically when the associated files change. If a chefspec test
|
67
|
+
fails, it will drop you into a pry session in the context of the
|
68
|
+
failure to explore the state of the run.
|
69
|
+
|
70
|
+
To disable the pry-rescue behavior, define the environment variable
|
71
|
+
DISABLE_PRY_RESCUE before running guard:
|
72
|
+
|
73
|
+
DISABLE_PRY_RESCUE=1 bin/guard
|
74
|
+
|
75
|
+
### Integration Tests
|
76
|
+
|
77
|
+
bin/rake kitchen:all
|
78
|
+
|
79
|
+
Will run the test kitchen integration tests. These tests use Vagrant
|
80
|
+
and Virtualbox, which must be installed for the tests to execute.
|
81
|
+
|
82
|
+
After converging in a virtual machine, ServerSpec tests are executed.
|
83
|
+
This skeleton comes with a very basic ServerSpec test; refer to
|
84
|
+
http://serverspec.org for detail on how to create tests.
|
85
|
+
|
86
|
+
## Author
|
87
|
+
|
88
|
+
<%= copyright_holder %>
|
89
|
+
|
90
|
+
## License
|
91
|
+
|
92
|
+
<%= license_description %>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'foodcritic'
|
2
|
+
require 'foodcritic/rake_task'
|
3
|
+
require 'tailor/rake_task'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'rubocop/rake_task'
|
6
|
+
require 'kitchen/rake_tasks'
|
7
|
+
|
8
|
+
# Style tests (Foodcritic / Rubocop)
|
9
|
+
FoodCritic::Rake::LintTask.new
|
10
|
+
RuboCop::RakeTask.new do |t|
|
11
|
+
t.formatters = ['progress']
|
12
|
+
t.options = ['-D']
|
13
|
+
t.patterns = %w(
|
14
|
+
attributes/*.rb
|
15
|
+
recipes/*.rb
|
16
|
+
libraries/**/*.rb
|
17
|
+
resources/*.rb
|
18
|
+
providers/*.rb
|
19
|
+
spec/**/*.rb
|
20
|
+
test/**/*.rb
|
21
|
+
./metadata.rb
|
22
|
+
./Berksfile
|
23
|
+
./Gemfile
|
24
|
+
./Rakefile
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
desc 'Run Style Tests'
|
29
|
+
task style: [:foodcritic, :rubocop]
|
30
|
+
|
31
|
+
# ChefSpec (RSpec)
|
32
|
+
RSpec::Core::RakeTask.new
|
33
|
+
|
34
|
+
desc 'Generate ChefSpec coverage report'
|
35
|
+
task :coverage do
|
36
|
+
ENV['COVERAGE'] = 'true'
|
37
|
+
Rake::Task[:spec].invoke
|
38
|
+
end
|
39
|
+
|
40
|
+
# Test Kitchen
|
41
|
+
begin
|
42
|
+
Kitchen::RakeTasks.new
|
43
|
+
rescue LoadError
|
44
|
+
puts 'test-kitchen initialization failed; disabling kitchen tasks'
|
45
|
+
end
|