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.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/ARUBA_STEPS.md +74 -0
  3. data/History.md +16 -0
  4. data/Manifest.txt +25 -30
  5. data/README.md +121 -16
  6. data/chef-gen-flavors.gemspec +8 -5
  7. data/lib/chef_gen/flavor_base.rb +42 -34
  8. data/lib/chef_gen/flavors.rb +36 -10
  9. data/lib/chef_gen/snippet/attributes.rb +13 -0
  10. data/lib/chef_gen/snippet/chef_spec.rb +84 -14
  11. data/lib/chef_gen/snippet/cookbook_base.rb +109 -23
  12. data/lib/chef_gen/snippet/example_file.rb +15 -0
  13. data/lib/chef_gen/snippet/example_template.rb +15 -0
  14. data/lib/chef_gen/snippet/git_init.rb +2 -0
  15. data/lib/chef_gen/snippet/recipes.rb +15 -0
  16. data/lib/chef_gen/snippet/resource_provider.rb +18 -0
  17. data/lib/chef_gen/snippet/standard_ignore.rb +56 -80
  18. data/lib/chef_gen/snippet/style_foodcritic.rb +51 -0
  19. data/lib/chef_gen/snippet/style_rubocop.rb +80 -0
  20. data/lib/chef_gen/snippet/style_tailor.rb +48 -0
  21. data/lib/chef_gen/snippet/test_kitchen.rb +70 -15
  22. data/lib/chef_gen/snippets.rb +2 -0
  23. data/shared/snippet/attributes/attributes_default_rb.erb +8 -0
  24. data/{.rspec → shared/snippet/chef_spec/_rspec.erb} +0 -0
  25. data/shared/snippet/chef_spec/spec_chef_runner_context_rb.erb +36 -0
  26. data/shared/snippet/chef_spec/spec_recipes_default_spec_rb.erb +7 -0
  27. data/shared/snippet/chef_spec/spec_spec_helper_rb.erb +95 -0
  28. data/shared/snippet/cookbookbase/Berksfile.erb +5 -0
  29. data/shared/snippet/cookbookbase/CHANGELOG_md.erb +5 -0
  30. data/shared/snippet/cookbookbase/Gemfile.erb +7 -0
  31. data/shared/snippet/cookbookbase/Guardfile.erb +10 -0
  32. data/shared/snippet/cookbookbase/README_md.erb +92 -0
  33. data/shared/snippet/cookbookbase/Rakefile.erb +20 -0
  34. data/shared/snippet/cookbookbase/metadata_rb.erb +10 -0
  35. data/shared/snippet/examplefile/files_default_example_conf +34 -0
  36. data/shared/snippet/exampletemplate/templates_default_example_conf_erb +22 -0
  37. data/shared/snippet/recipes/recipes_default_rb.erb +9 -0
  38. data/shared/snippet/resourceprovider/providers_default_rb.erb +20 -0
  39. data/shared/snippet/resourceprovider/resources_default_rb.erb +9 -0
  40. data/shared/snippet/stylerubocop/_rubocop_yml.erb +27 -0
  41. data/shared/snippet/testkitchen/_kitchen_yml.erb +30 -0
  42. data/shared/snippet/testkitchen/libraries_kitchen_helper_rb +13 -0
  43. data/shared/snippet/testkitchen/test_integration_default_serverspec_recipes_default_spec_rb.erb +16 -0
  44. data/shared/snippet/testkitchen/test_integration_default_serverspec_spec_helper_rb.erb +7 -0
  45. metadata +42 -32
  46. data/.rubocop.yml +0 -27
  47. data/.travis.yml +0 -6
  48. data/Gemfile +0 -3
  49. data/Guardfile +0 -15
  50. data/Rakefile +0 -98
  51. data/features/generate.feature +0 -17
  52. data/features/support/env.rb +0 -15
  53. data/spec/lib/chef_gen/flavor_base_spec.rb +0 -167
  54. data/spec/lib/chef_gen/flavors_spec.rb +0 -132
  55. data/spec/lib/chef_gen/snippet/attributes_spec.rb +0 -40
  56. data/spec/lib/chef_gen/snippet/chef_spec_spec.rb +0 -40
  57. data/spec/lib/chef_gen/snippet/cookbook_base_spec.rb +0 -32
  58. data/spec/lib/chef_gen/snippet/example_file_spec.rb +0 -40
  59. data/spec/lib/chef_gen/snippet/example_template_spec.rb +0 -40
  60. data/spec/lib/chef_gen/snippet/git_init_spec.rb +0 -30
  61. data/spec/lib/chef_gen/snippet/recipes_spec.rb +0 -40
  62. data/spec/lib/chef_gen/snippet/resource_provider_spec.rb +0 -40
  63. data/spec/lib/chef_gen/snippet/standard_ignore_spec.rb +0 -35
  64. data/spec/lib/chef_gen/snippet/style_rubocop_spec.rb +0 -31
  65. data/spec/lib/chef_gen/snippet/test_kitchen_spec.rb +0 -44
  66. data/spec/spec_helper.rb +0 -64
  67. data/spec/support/fixtures/code_generator/metadata.rb +0 -2
  68. data/spec/support/fixtures/code_generator/recipes/cookbook.rb +0 -1
  69. data/spec/support/fixtures/code_generator_2/metadata.rb +0 -2
  70. data/spec/support/fixtures/code_generator_2/recipes/cookbook.rb +0 -3
  71. data/spec/support/fixtures/code_generator_2/templates/default/README_md.erb +0 -1
  72. data/spec/support/fixtures/lib/chef_gen/flavor/bar.rb +0 -21
  73. data/spec/support/fixtures/lib/chef_gen/flavor/baz.rb +0 -6
  74. data/spec/support/fixtures/lib/chef_gen/flavor/foo.rb +0 -9
@@ -0,0 +1,30 @@
1
+ <%% proxy_vars = {} %>
2
+ <%% %w(http_proxy https_proxy no_proxy).each do |envvar| %>
3
+ <%% if ENV.key?(envvar) %>
4
+ <%% proxy_vars[envvar] = ENV[envvar] %>
5
+ <%% end %>
6
+ <%% end %>
7
+ ---
8
+ driver:
9
+ name: vagrant
10
+
11
+ <%% if proxy_vars.size > 0 %>
12
+ driver_config:
13
+ <%= kitchen_proxy_vars(2) %>
14
+ <%% end %>
15
+
16
+ provisioner:
17
+ name: chef_zero
18
+ <%% if proxy_vars.size > 0 %>
19
+ client_rb:
20
+ <%= kitchen_proxy_vars(4) %>
21
+ <%% end %>
22
+
23
+ platforms:
24
+ - name: ubuntu-14.04
25
+ - name: centos-6.6
26
+
27
+ suites:
28
+ - name: default
29
+ run_list:
30
+ - recipe[<%= cookbook_name %>::default]
@@ -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,16 @@
1
+ #
2
+ # Copyright (c) <%= year %> <%= copyright_holder %>
3
+ #
4
+
5
+ require 'spec_helper'
6
+
7
+ # this is a generic ServerSpec test. It just runs 'whoami'
8
+ # and confirms that it returns 'root'. In a real test suite,
9
+ # you would want to test things like directories, users,
10
+ # processes, services, etc.
11
+ #
12
+ # for more information on the things ServerSpec can test, refer
13
+ # to the documentation at http://serverspec.org
14
+ describe command('whoami') do
15
+ its(:stdout) { should eq "root\n" }
16
+ end
@@ -0,0 +1,7 @@
1
+ #
2
+ # Copyright (c) <%= year %> <%= copyright_holder %>
3
+ #
4
+
5
+ require 'serverspec'
6
+
7
+ set :backend, :exec
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-gen-flavors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James FitzGibbon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-05 00:00:00.000000000 Z
11
+ date: 2015-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: little-plugger
@@ -248,6 +248,20 @@ dependencies:
248
248
  - - "~>"
249
249
  - !ruby/object:Gem::Version
250
250
  version: '0.2'
251
+ - !ruby/object:Gem::Dependency
252
+ name: fakefs
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - "~>"
256
+ - !ruby/object:Gem::Version
257
+ version: '0.6'
258
+ type: :development
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - "~>"
263
+ - !ruby/object:Gem::Version
264
+ version: '0.6'
251
265
  description: |-
252
266
  chef-gen-flavors is a framework for creating custom templates for the
253
267
  'chef generate' command provided by ChefDK.
@@ -265,23 +279,17 @@ email:
265
279
  executables: []
266
280
  extensions: []
267
281
  extra_rdoc_files:
282
+ - ARUBA_STEPS.md
268
283
  - History.md
269
284
  - Manifest.txt
270
285
  - README.md
271
286
  files:
272
- - ".rspec"
273
- - ".rubocop.yml"
274
- - ".travis.yml"
275
- - Gemfile
276
- - Guardfile
287
+ - ARUBA_STEPS.md
277
288
  - History.md
278
289
  - LICENSE
279
290
  - Manifest.txt
280
291
  - README.md
281
- - Rakefile
282
292
  - chef-gen-flavors.gemspec
283
- - features/generate.feature
284
- - features/support/env.rb
285
293
  - lib/chef_gen/flavor.rb
286
294
  - lib/chef_gen/flavor_base.rb
287
295
  - lib/chef_gen/flavors.rb
@@ -301,31 +309,33 @@ files:
301
309
  - lib/chef_gen/snippet/recipes.rb
302
310
  - lib/chef_gen/snippet/resource_provider.rb
303
311
  - lib/chef_gen/snippet/standard_ignore.rb
312
+ - lib/chef_gen/snippet/style_foodcritic.rb
304
313
  - lib/chef_gen/snippet/style_rubocop.rb
314
+ - lib/chef_gen/snippet/style_tailor.rb
305
315
  - lib/chef_gen/snippet/test_kitchen.rb
306
316
  - lib/chef_gen/snippets.rb
307
- - spec/lib/chef_gen/flavor_base_spec.rb
308
- - spec/lib/chef_gen/flavors_spec.rb
309
- - spec/lib/chef_gen/snippet/attributes_spec.rb
310
- - spec/lib/chef_gen/snippet/chef_spec_spec.rb
311
- - spec/lib/chef_gen/snippet/cookbook_base_spec.rb
312
- - spec/lib/chef_gen/snippet/example_file_spec.rb
313
- - spec/lib/chef_gen/snippet/example_template_spec.rb
314
- - spec/lib/chef_gen/snippet/git_init_spec.rb
315
- - spec/lib/chef_gen/snippet/recipes_spec.rb
316
- - spec/lib/chef_gen/snippet/resource_provider_spec.rb
317
- - spec/lib/chef_gen/snippet/standard_ignore_spec.rb
318
- - spec/lib/chef_gen/snippet/style_rubocop_spec.rb
319
- - spec/lib/chef_gen/snippet/test_kitchen_spec.rb
320
- - spec/spec_helper.rb
321
- - spec/support/fixtures/code_generator/metadata.rb
322
- - spec/support/fixtures/code_generator/recipes/cookbook.rb
323
- - spec/support/fixtures/code_generator_2/metadata.rb
324
- - spec/support/fixtures/code_generator_2/recipes/cookbook.rb
325
- - spec/support/fixtures/code_generator_2/templates/default/README_md.erb
326
- - spec/support/fixtures/lib/chef_gen/flavor/bar.rb
327
- - spec/support/fixtures/lib/chef_gen/flavor/baz.rb
328
- - spec/support/fixtures/lib/chef_gen/flavor/foo.rb
317
+ - shared/snippet/attributes/attributes_default_rb.erb
318
+ - shared/snippet/chef_spec/_rspec.erb
319
+ - shared/snippet/chef_spec/spec_chef_runner_context_rb.erb
320
+ - shared/snippet/chef_spec/spec_recipes_default_spec_rb.erb
321
+ - shared/snippet/chef_spec/spec_spec_helper_rb.erb
322
+ - shared/snippet/cookbookbase/Berksfile.erb
323
+ - shared/snippet/cookbookbase/CHANGELOG_md.erb
324
+ - shared/snippet/cookbookbase/Gemfile.erb
325
+ - shared/snippet/cookbookbase/Guardfile.erb
326
+ - shared/snippet/cookbookbase/README_md.erb
327
+ - shared/snippet/cookbookbase/Rakefile.erb
328
+ - shared/snippet/cookbookbase/metadata_rb.erb
329
+ - shared/snippet/examplefile/files_default_example_conf
330
+ - shared/snippet/exampletemplate/templates_default_example_conf_erb
331
+ - shared/snippet/recipes/recipes_default_rb.erb
332
+ - shared/snippet/resourceprovider/providers_default_rb.erb
333
+ - shared/snippet/resourceprovider/resources_default_rb.erb
334
+ - shared/snippet/stylerubocop/_rubocop_yml.erb
335
+ - shared/snippet/testkitchen/_kitchen_yml.erb
336
+ - shared/snippet/testkitchen/libraries_kitchen_helper_rb
337
+ - shared/snippet/testkitchen/test_integration_default_serverspec_recipes_default_spec_rb.erb
338
+ - shared/snippet/testkitchen/test_integration_default_serverspec_spec_helper_rb.erb
329
339
  homepage: https://github.com/Nordstrom/chef-gen-flavors
330
340
  licenses:
331
341
  - apache2
data/.rubocop.yml DELETED
@@ -1,27 +0,0 @@
1
- AllCops:
2
- Exclude:
3
- - '**/Gemfile'
4
- - '**/*.gemspec'
5
- - 'pkg/**/*'
6
-
7
- Style/RegexpLiteral:
8
- Exclude:
9
- - '**/Guardfile'
10
-
11
- Style/Documentation:
12
- Exclude:
13
- - 'spec/**/*.rb'
14
-
15
- Metrics/MethodLength:
16
- Max: 15
17
-
18
- Metrics/ClassLength:
19
- Max: 150
20
-
21
- Lint/UnusedMethodArgument:
22
- Exclude:
23
- - 'lib/chef_gen/snippet/*.rb'
24
-
25
- Metrics/LineLength:
26
- Exclude:
27
- - 'lib/chef_gen/flavors/cucumber/*.rb'
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - "2.1.6"
4
- - "2.2.2"
5
- install: bundle install --binstubs
6
- env: TRAVIS_BUILD=true
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org/'
2
-
3
- gemspec
data/Guardfile DELETED
@@ -1,15 +0,0 @@
1
- # prevent dropping into pry when nothing is happening
2
- interactor :off
3
-
4
- guard :rubocop, all_on_start: true, cli: ['-D'] do
5
- watch(%r{.+\.rb$})
6
- watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
7
- watch('Gemfile')
8
- watch('Rakefile')
9
- end
10
-
11
- guard :rspec, all_on_start: true, cmd: 'bundle exec rspec' do
12
- watch(%r{^spec/(.+)_spec\.rb$})
13
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
14
- watch(%r{^spec/spec_helper.*\.rb$}) { 'spec' }
15
- end
data/Rakefile DELETED
@@ -1,98 +0,0 @@
1
- require 'chef_gen/flavors'
2
-
3
- begin
4
- require 'hoe'
5
- Hoe.plugin :gemspec
6
- Hoe.plugins.delete :test
7
- Hoe.spec 'chef-gen-flavors' do |s|
8
- s.version = ChefGen::Flavors::VERSION
9
- developer 'James FitzGibbon', 'james.i.fitzgibbon@nordstrom.com'
10
- license 'apache2'
11
- extra_deps << ['little-plugger', '~> 1.1']
12
- extra_deps << ['bogo-ui', '~> 0.1']
13
- extra_dev_deps << ['chef-dk', '~> 0.5']
14
- extra_dev_deps << ['hoe', '~> 3.13']
15
- extra_dev_deps << ['hoe-gemspec', '~> 1.0']
16
- extra_dev_deps << ['rake', '~> 10.3']
17
- extra_dev_deps << ['rspec', '~> 3.1']
18
- extra_dev_deps << ['guard', '~> 2.12']
19
- extra_dev_deps << ['guard-rspec', '~> 4.2']
20
- extra_dev_deps << ['guard-rake', '~> 0.0']
21
- extra_dev_deps << ['guard-rubocop', '~> 1.2']
22
- extra_dev_deps << ['simplecov', '~> 0.9']
23
- extra_dev_deps << ['simplecov-console', '~> 0.2']
24
- extra_dev_deps << ['yard', '~> 0.8']
25
- extra_dev_deps << ['aruba', '~> 0.6']
26
- extra_dev_deps << ['rspec_junit_formatter', '~> 0.2']
27
- end
28
- # re-generate our gemspec before packaging
29
- task package: 'gem:spec'
30
- rescue LoadError
31
- puts 'hoe not available; disabling tasks'
32
- end
33
-
34
- # Style Tests
35
- begin
36
- require 'rubocop/rake_task'
37
- RuboCop::RakeTask.new do |t|
38
- t.formatters = ['progress']
39
- t.options = ['-D']
40
- t.patterns = %w(
41
- lib/**/*.rb
42
- spec/**/*.rb
43
- ./Rakefile
44
- )
45
- end
46
- desc 'Run Style Tests'
47
- task style: [:rubocop]
48
- rescue LoadError
49
- puts 'rubocop not available; disabling tasks'
50
- end
51
-
52
- # Unit Tests
53
- begin
54
- require 'rspec/core/rake_task'
55
- RSpec::Core::RakeTask.new
56
-
57
- # Coverage
58
- desc 'Generate unit test coverage report'
59
- task :coverage do
60
- ENV['COVERAGE'] = 'true'
61
- Rake::Task[:test].invoke
62
- end
63
- rescue LoadError
64
- puts 'rspec not available; disabling tasks'
65
- # create a no-op task so that :default works
66
- task :test
67
- end
68
-
69
- # Feature Tests
70
- begin
71
- require 'cucumber'
72
- require 'cucumber/rake/task'
73
- Cucumber::Rake::Task.new(:features)
74
- rescue LoadError
75
- puts 'Cucumber/Aruba not available; disabling feature tasks'
76
- # create a no-op spec task for :default
77
- task :features
78
- end
79
-
80
- # Documentation
81
- begin
82
- require 'yard'
83
- require 'yard/rake/yardoc_task'
84
- YARD::Rake::YardocTask.new(:doc) do |t|
85
- t.options = ['-m', 'markdown', '--private']
86
- t.stats_options = ['--list-undoc']
87
- end
88
- rescue LoadError
89
- puts 'yard not available; disabling tasks'
90
- end
91
-
92
- # test is an alias for spec and features
93
- desc 'runs unit and feature tests'
94
- task test: [:spec, :features]
95
-
96
- # default is to test everything
97
- desc 'runs all tests'
98
- task default: :test
@@ -1,17 +0,0 @@
1
- Feature: chef generate
2
-
3
- Verifies that 'chef generate cookbook' works when the generator
4
- path is dynamically chosen by chef-gen-flavors
5
-
6
- Scenario: generate cookbook
7
- Given a knife.rb that uses chef-gen-flavors
8
- And I set the environment variables to:
9
- | variable | value |
10
- |----------------|----------------------------------|
11
- | CHEFGEN_FLAVOR | bar |
12
- | RUBYLIB | ../../spec/support/fixtures/lib |
13
- When I generate a cookbook named "foo"
14
- Then the exit status should be 0
15
- And the output should match /using ChefGen flavor 'bar'/
16
- And the output should match /Recipe: code_generator_2::cookbook/
17
- And the output should match /- create new file README.md/
@@ -1,15 +0,0 @@
1
- if ENV['COVERAGE']
2
- require 'simplecov'
3
- end
4
-
5
- require 'aruba/cucumber'
6
- require 'chef_gen/flavors/cucumber'
7
-
8
- # Travis runs tests in a limited environment which takes a long time to invoke
9
- # the knife command. Up the timeout when we're in a travis build based on the
10
- # environment variable set in .travis.yml
11
- if ENV['TRAVIS_BUILD']
12
- Before do
13
- @aruba_timeout_seconds = 15
14
- end
15
- end
@@ -1,167 +0,0 @@
1
- require 'chef_gen/flavor_base'
2
-
3
- # :nocov:
4
- module ChefGen
5
- module Flavor
6
- class Amazing < FlavorBase
7
- class << self
8
- def description
9
- 'an amazing cookbook template'
10
- end
11
- end
12
- end
13
- end
14
- module Snippet
15
- module Bar
16
- def snippet_bar(_)
17
- @directories << 'bar'
18
- end
19
- end
20
- end
21
- end
22
- # :nocov:
23
-
24
- RSpec.describe ChefGen::FlavorBase do
25
- include ChefDKGeneratorContext
26
- include DummyRecipe
27
-
28
- before do
29
- @orig_stdout = $stdout
30
- $stdout = File.open(File::NULL, 'w')
31
- end
32
-
33
- after do
34
- $stdout = @orig_stdout
35
- end
36
-
37
- it 'can be constructed' do
38
- template = ChefGen::Flavor::Amazing.new(@recipe)
39
- expect(template).to be_a ChefGen::FlavorBase
40
- end
41
-
42
- it 'creates files unconditionally' do
43
- expect(@recipe).to receive(:directory).once
44
- expect(@recipe).to receive(:cookbook_file).once
45
- template = ChefGen::Flavor::Amazing.new(@recipe)
46
- template.files << 'README.md'
47
- template.generate
48
- end
49
-
50
- it 'creates files conditionally with the clobber check enabled' do
51
- expect(@recipe).to receive(:directory).once
52
- expect(@recipe).not_to receive(:cookbook_file)
53
- expect(File).to receive(:exist?)
54
- .with('/nonexistent/foo/README.md')
55
- .and_return(true)
56
- template = ChefGen::Flavor::Amazing.new(@recipe)
57
- template.fail_on_clobber = true
58
- template.files << 'README.md'
59
- expect { template.generate }
60
- .to output(/tried to overwrite file.+README\.md/).to_stderr
61
- .and raise_error
62
- end
63
-
64
- it 'creates files conditionally with the clobber check disabled' do
65
- expect(@recipe).to receive(:directory).once
66
- expect(@recipe).to receive(:cookbook_file).once
67
- expect(@ctx).to receive(:respond_to?).with(:clobber).and_return(true)
68
- template = ChefGen::Flavor::Amazing.new(@recipe)
69
- template.files << 'README.md'
70
- template.generate
71
- end
72
-
73
- it 'creates templates unconditionally' do
74
- expect(@recipe).to receive(:directory).once
75
- expect(@recipe).to receive(:template).once
76
- template = ChefGen::Flavor::Amazing.new(@recipe)
77
- template.templates << 'README.md'
78
- template.generate
79
- end
80
-
81
- it 'creates templates conditionally with the clobber check enabled' do
82
- expect(@recipe).to receive(:directory).once
83
- expect(@recipe).not_to receive(:template)
84
- expect(File).to receive(:exist?)
85
- .with('/nonexistent/foo/README.md')
86
- .and_return(true)
87
- template = ChefGen::Flavor::Amazing.new(@recipe)
88
- template.fail_on_clobber = true
89
- template.templates << 'README.md'
90
- expect { template.generate }
91
- .to output(/tried to overwrite file.+README\.md/).to_stderr
92
- .and raise_error
93
- end
94
-
95
- it 'creates templates conditionally with the clobber check disabled' do
96
- expect(@recipe).to receive(:directory).once
97
- expect(@recipe).to receive(:template).once
98
- expect(@ctx).to receive(:respond_to?).with(:clobber).and_return(true)
99
- template = ChefGen::Flavor::Amazing.new(@recipe)
100
- template.templates << 'README.md'
101
- template.generate
102
- end
103
-
104
- it 'accumulates .gitignore entries' do
105
- expect(@recipe).to receive(:file).with(/.gitignore$/)
106
- template = ChefGen::Flavor::Amazing.new(@recipe)
107
- template.gitignore_files << 'foo'
108
- template.gitignore_files << 'bar'
109
- template.generate
110
- end
111
-
112
- it 'does not write a .gitignore if there are no entries' do
113
- expect(@recipe).not_to receive(:cookbook_file).with(/.gitignore$/)
114
- template = ChefGen::Flavor::Amazing.new(@recipe)
115
- template.generate
116
- end
117
-
118
- it 'accumulates chefignore entries' do
119
- expect(@recipe).to receive(:file).with(/chefignore$/)
120
- template = ChefGen::Flavor::Amazing.new(@recipe)
121
- template.chefignore_files << 'foo'
122
- template.chefignore_files << 'bar'
123
- template.generate
124
- end
125
-
126
- it 'does not write a chefignore if there are no entries' do
127
- expect(@recipe).not_to receive(:cookbook_file).with(/chefignore$/)
128
- template = ChefGen::Flavor::Amazing.new(@recipe)
129
- template.generate
130
- end
131
-
132
- it 'calls mixin methods' do
133
- expect(@recipe).to receive(:directory).with(/foo$/)
134
- expect(@recipe).to receive(:directory).with(%r{foo/bar$})
135
- template = ChefGen::Flavor::Amazing.new(@recipe)
136
- template.extend ChefGen::Snippet::Bar
137
- template.generate
138
- end
139
-
140
- it 'reports on actions by default' do
141
- expect(@recipe).to receive(:ruby_block).with('report_actions_taken')
142
- template = ChefGen::Flavor::Amazing.new(@recipe)
143
- template.files << 'README.md'
144
- template.generate
145
- end
146
-
147
- it 'does not report actions if disabled' do
148
- expect(@recipe).not_to receive(:ruby_block)
149
- template = ChefGen::Flavor::Amazing.new(@recipe)
150
- template.report_actions = false
151
- template.files << 'README.md'
152
- template.generate
153
- end
154
-
155
- it 'displays the next steps if populated' do
156
- expect(@recipe).to receive(:ruby_block).with('display_next_steps')
157
- template = ChefGen::Flavor::Amazing.new(@recipe)
158
- template.report_actions = false
159
- template.next_steps = 'do something amazing'
160
- template.generate
161
- end
162
-
163
- it 'proxies to the ChefDK generator context' do
164
- template = ChefGen::Flavor::Amazing.new(@recipe)
165
- template.generator_context
166
- end
167
- end