chef-dk 0.3.5 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +4 -4
  3. data/README.md +4 -4
  4. data/lib/chef-dk/builtin_commands.rb +4 -0
  5. data/lib/chef-dk/chef_runner.rb +7 -1
  6. data/lib/chef-dk/command/exec.rb +9 -0
  7. data/lib/chef-dk/command/export.rb +132 -0
  8. data/lib/chef-dk/command/generator_commands.rb +1 -1
  9. data/lib/chef-dk/command/generator_commands/app.rb +8 -0
  10. data/lib/chef-dk/command/generator_commands/base.rb +46 -4
  11. data/lib/chef-dk/command/generator_commands/cookbook.rb +8 -0
  12. data/lib/chef-dk/command/generator_commands/cookbook_code_file.rb +1 -0
  13. data/lib/chef-dk/command/push.rb +3 -6
  14. data/lib/chef-dk/command/shell_init.rb +28 -5
  15. data/lib/chef-dk/command/update.rb +106 -0
  16. data/lib/chef-dk/command/verify.rb +72 -0
  17. data/lib/chef-dk/component_test.rb +12 -1
  18. data/lib/chef-dk/configurable.rb +52 -0
  19. data/lib/chef-dk/cookbook_metadata.rb +10 -1
  20. data/lib/chef-dk/cookbook_profiler/git.rb +1 -1
  21. data/lib/chef-dk/exceptions.rb +17 -2
  22. data/lib/chef-dk/helpers.rb +2 -2
  23. data/lib/chef-dk/policyfile/community_cookbook_source.rb +1 -1
  24. data/lib/chef-dk/policyfile/dsl.rb +7 -0
  25. data/lib/chef-dk/policyfile/uploader.rb +25 -4
  26. data/lib/chef-dk/policyfile_compiler.rb +21 -1
  27. data/lib/chef-dk/policyfile_lock.rb +5 -0
  28. data/lib/chef-dk/policyfile_services/export_repo.rb +194 -0
  29. data/lib/chef-dk/policyfile_services/install.rb +8 -2
  30. data/lib/chef-dk/policyfile_services/push.rb +4 -1
  31. data/lib/chef-dk/service_exceptions.rb +6 -0
  32. data/lib/chef-dk/skeletons/code_generator/files/default/Berksfile +1 -1
  33. data/lib/chef-dk/skeletons/code_generator/files/default/repo/README.md +1 -1
  34. data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/README.md +1 -1
  35. data/lib/chef-dk/skeletons/code_generator/files/default/repo/environments/README.md +2 -2
  36. data/lib/chef-dk/skeletons/code_generator/files/default/serverspec_spec_helper.rb +3 -0
  37. data/lib/chef-dk/skeletons/code_generator/files/default/spec_helper.rb +1 -7
  38. data/lib/chef-dk/skeletons/code_generator/metadata.rb +1 -1
  39. data/lib/chef-dk/skeletons/code_generator/recipes/app.rb +31 -1
  40. data/lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb +32 -2
  41. data/lib/chef-dk/skeletons/code_generator/recipes/recipe.rb +18 -0
  42. data/lib/chef-dk/skeletons/code_generator/templates/default/recipe.rb.erb +5 -0
  43. data/lib/chef-dk/skeletons/code_generator/templates/default/recipe_spec.rb.erb +23 -0
  44. data/lib/chef-dk/skeletons/code_generator/templates/default/serverspec_default_spec.rb.erb +12 -0
  45. data/lib/chef-dk/version.rb +1 -1
  46. data/lib/kitchen/provisioner/policyfile_zero.rb +149 -0
  47. data/spec/shared/a_file_generator.rb +1 -0
  48. data/spec/shared/command_with_ui_object.rb +11 -0
  49. data/spec/shared/custom_generator_cookbook.rb +117 -0
  50. data/spec/unit/chef_runner_spec.rb +26 -0
  51. data/spec/unit/command/exec_spec.rb +46 -5
  52. data/spec/unit/command/export_spec.rb +176 -0
  53. data/spec/unit/command/generator_commands/app_spec.rb +38 -0
  54. data/spec/unit/command/generator_commands/cookbook_spec.rb +37 -28
  55. data/spec/unit/command/generator_commands/recipe_spec.rb +4 -2
  56. data/spec/unit/command/install_spec.rb +3 -6
  57. data/spec/unit/command/push_spec.rb +3 -6
  58. data/spec/unit/command/shell_init_spec.rb +77 -49
  59. data/spec/unit/command/update_spec.rb +155 -0
  60. data/spec/unit/command/verify_spec.rb +22 -7
  61. data/spec/unit/cookbook_metadata_spec.rb +44 -8
  62. data/spec/unit/cookbook_profiler/git_spec.rb +12 -0
  63. data/spec/unit/fixtures/cookbook_cache/baz-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/Berksfile +1 -1
  64. data/spec/unit/fixtures/cookbook_cache/dep_of_bar-1.2.3/Berksfile +1 -1
  65. data/spec/unit/fixtures/cookbook_cache/foo-1.0.0/Berksfile +1 -1
  66. data/spec/unit/fixtures/cookbooks_api/small_universe.json +667 -667
  67. data/spec/unit/fixtures/cookbooks_api/universe.json +1 -1
  68. data/spec/unit/fixtures/cookbooks_api/update_fixtures.rb +1 -1
  69. data/spec/unit/fixtures/example_cookbook/Berksfile +1 -1
  70. data/spec/unit/fixtures/example_cookbook_metadata_json_only/.gitignore +17 -0
  71. data/spec/unit/fixtures/example_cookbook_metadata_json_only/.kitchen.yml +16 -0
  72. data/spec/unit/fixtures/example_cookbook_metadata_json_only/Berksfile +3 -0
  73. data/spec/unit/fixtures/example_cookbook_metadata_json_only/README.md +4 -0
  74. data/spec/unit/fixtures/example_cookbook_metadata_json_only/chefignore +96 -0
  75. data/spec/unit/fixtures/example_cookbook_metadata_json_only/metadata.json +5 -0
  76. data/spec/unit/fixtures/example_cookbook_metadata_json_only/recipes/default.rb +8 -0
  77. data/spec/unit/fixtures/example_cookbook_no_metadata/.gitignore +17 -0
  78. data/spec/unit/fixtures/example_cookbook_no_metadata/.kitchen.yml +16 -0
  79. data/spec/unit/fixtures/example_cookbook_no_metadata/Berksfile +3 -0
  80. data/spec/unit/fixtures/example_cookbook_no_metadata/README.md +4 -0
  81. data/spec/unit/fixtures/example_cookbook_no_metadata/chefignore +96 -0
  82. data/spec/unit/fixtures/example_cookbook_no_metadata/recipes/default.rb +8 -0
  83. data/spec/unit/fixtures/local_path_cookbooks/local-cookbook/Berksfile +1 -1
  84. data/spec/unit/policyfile/community_cookbook_source_spec.rb +2 -2
  85. data/spec/unit/policyfile/cookbook_location_specification_spec.rb +3 -3
  86. data/spec/unit/policyfile/uploader_spec.rb +61 -25
  87. data/spec/unit/policyfile_demands_spec.rb +47 -0
  88. data/spec/unit/policyfile_evaluation_spec.rb +1 -1
  89. data/spec/unit/policyfile_lock_build_spec.rb +60 -3
  90. data/spec/unit/policyfile_services/export_repo_spec.rb +321 -0
  91. data/spec/unit/policyfile_services/install_spec.rb +20 -1
  92. data/spec/unit/policyfile_services/push_spec.rb +36 -9
  93. metadata +53 -38
  94. data/lib/chef-dk/skeletons/code_generator/files/default/converge_spec.rb +0 -9
  95. data/lib/chef-dk/skeletons/code_generator/templates/default/default_recipe.rb.erb +0 -5
@@ -80,6 +80,7 @@ module ChefDK
80
80
 
81
81
  attr_accessor :name
82
82
  attr_accessor :run_list
83
+ attr_accessor :named_run_lists
83
84
 
84
85
  attr_reader :solution_dependencies
85
86
 
@@ -92,6 +93,7 @@ module ChefDK
92
93
  def initialize(storage_config, ui: nil)
93
94
  @name = nil
94
95
  @run_list = []
96
+ @named_run_lists = {}
95
97
  @cookbook_locks = {}
96
98
  @relative_paths_root = Dir.pwd
97
99
  @storage_config = storage_config
@@ -125,6 +127,7 @@ module ChefDK
125
127
  {}.tap do |lock|
126
128
  lock["name"] = name
127
129
  lock["run_list"] = run_list
130
+ lock["named_run_lists"] = named_run_lists unless named_run_lists.empty?
128
131
  lock["cookbook_locks"] = cookbook_locks_for_lockfile
129
132
  lock["solution_dependencies"] = solution_dependencies.to_lock
130
133
  end
@@ -170,6 +173,8 @@ module ChefDK
170
173
 
171
174
  @run_list = compiler.normalized_run_list
172
175
 
176
+ @named_run_lists = compiler.normalized_named_run_lists
177
+
173
178
  compiler.all_cookbook_location_specs.each do |cookbook_name, spec|
174
179
  if spec.mirrors_canonical_upstream?
175
180
  cached_cookbook(cookbook_name) do |cached_cb|
@@ -0,0 +1,194 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2014 Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'fileutils'
19
+
20
+ require 'chef-dk/service_exceptions'
21
+ require 'chef-dk/policyfile_lock'
22
+ require 'chef-dk/policyfile/storage_config'
23
+
24
+ module ChefDK
25
+ module PolicyfileServices
26
+
27
+ class ExportRepo
28
+
29
+ # Policy groups provide namespaces for policies so that a Chef Server can
30
+ # have multiple active iterations of a policy at once, but we don't need
31
+ # this when serving a single exported policy via Chef Zero, so hardcode
32
+ # it to a "well known" value:
33
+ POLICY_GROUP = 'local'.freeze
34
+
35
+ include Policyfile::StorageConfigDelegation
36
+
37
+ attr_reader :storage_config
38
+ attr_reader :root_dir
39
+ attr_reader :export_dir
40
+
41
+ def initialize(policyfile: nil, export_dir: nil, root_dir: nil, force: false)
42
+ @root_dir = root_dir
43
+ @export_dir = File.expand_path(export_dir)
44
+ @force_export = force
45
+
46
+ @policy_data = nil
47
+ @policyfile_lock = nil
48
+
49
+ policyfile_rel_path = policyfile || "Policyfile.rb"
50
+ policyfile_full_path = File.expand_path(policyfile_rel_path, root_dir)
51
+ @storage_config = Policyfile::StorageConfig.new.use_policyfile(policyfile_full_path)
52
+ end
53
+
54
+ def policy_name
55
+ policyfile_lock.name
56
+ end
57
+
58
+ def run
59
+ assert_lockfile_exists!
60
+ assert_export_dir_clean!
61
+
62
+ validate_lockfile
63
+ write_updated_lockfile
64
+ export
65
+ end
66
+
67
+ def policy_data
68
+ @policy_data ||= FFI_Yajl::Parser.parse(IO.read(policyfile_lock_expanded_path))
69
+ rescue => error
70
+ raise PolicyfileExportRepoError.new("Error reading lockfile #{policyfile_lock_expanded_path}", error)
71
+ end
72
+
73
+ def policyfile_lock
74
+ @policyfile_lock || validate_lockfile
75
+ end
76
+
77
+ def export
78
+ create_repo_structure
79
+ copy_cookbooks
80
+ create_policyfile_data_item
81
+ rescue => error
82
+ msg = "Failed to export policy (in #{policyfile_filename}) to #{export_dir}"
83
+ raise PolicyfileExportRepoError.new(msg, error)
84
+ end
85
+
86
+ private
87
+
88
+ def create_repo_structure
89
+ FileUtils.rm_rf(cookbooks_dir)
90
+ FileUtils.rm_rf(policyfiles_data_bag_dir)
91
+
92
+ FileUtils.mkdir_p(export_dir)
93
+ FileUtils.mkdir_p(cookbooks_dir)
94
+ FileUtils.mkdir_p(policyfiles_data_bag_dir)
95
+ end
96
+
97
+ def copy_cookbooks
98
+ policyfile_lock.cookbook_locks.each do |name, lock|
99
+ copy_cookbook(lock)
100
+ end
101
+ end
102
+
103
+ def copy_cookbook(lock)
104
+ dirname = "#{lock.name}-#{lock.dotted_decimal_identifier}"
105
+ export_path = File.join(export_dir, "cookbooks", dirname)
106
+ metadata_rb_path = File.join(export_path, "metadata.rb")
107
+ FileUtils.cp_r(lock.cookbook_path, export_path)
108
+ FileUtils.rm_f(metadata_rb_path)
109
+ metadata = lock.cookbook_version.metadata
110
+ metadata.version(lock.dotted_decimal_identifier)
111
+
112
+ metadata_json_path = File.join(export_path, "metadata.json")
113
+
114
+ File.open(metadata_json_path, "wb+") do |f|
115
+ f.print(FFI_Yajl::Encoder.encode(metadata.to_hash, pretty: true ))
116
+ end
117
+ end
118
+
119
+ def create_policyfile_data_item
120
+ policy_id = "#{policyfile_lock.name}-#{POLICY_GROUP}"
121
+ item_path = File.join(export_dir, "data_bags", "policyfiles", "#{policy_id}.json")
122
+
123
+ lock_data = policyfile_lock.to_lock.dup
124
+
125
+ lock_data["id"] = policy_id
126
+
127
+ data_item = {
128
+ "id" => policy_id,
129
+ "name" => "data_bag_item_policyfiles_#{policy_id}",
130
+ "data_bag" => "policyfiles",
131
+ "raw_data" => lock_data,
132
+ # we'd prefer to leave this out, but the "compatibility mode"
133
+ # implementation in chef-client relies on magical class inflation
134
+ "json_class" => "Chef::DataBagItem"
135
+ }
136
+
137
+ File.open(item_path, "wb+") do |f|
138
+ f.print(FFI_Yajl::Encoder.encode(data_item, pretty: true ))
139
+ end
140
+ end
141
+
142
+ def validate_lockfile
143
+ return @policyfile_lock if @policyfile_lock
144
+ @policyfile_lock = ChefDK::PolicyfileLock.new(storage_config).build_from_lock_data(policy_data)
145
+ # TODO: enumerate any cookbook that have been updated
146
+ @policyfile_lock.validate_cookbooks!
147
+ @policyfile_lock
148
+ rescue PolicyfileExportRepoError
149
+ raise
150
+ rescue => error
151
+ raise PolicyfileExportRepoError.new("Invalid lockfile data", error)
152
+ end
153
+
154
+ def write_updated_lockfile
155
+ File.open(policyfile_lock_expanded_path, "wb+") do |f|
156
+ f.print(FFI_Yajl::Encoder.encode(policyfile_lock.to_lock, pretty: true ))
157
+ end
158
+ end
159
+
160
+ def assert_lockfile_exists!
161
+ unless File.exist?(policyfile_lock_expanded_path)
162
+ raise LockfileNotFound, "No lockfile at #{policyfile_lock_expanded_path} - you need to run `install` before `push`"
163
+ end
164
+ end
165
+
166
+ def assert_export_dir_clean!
167
+ if !force_export? && !conflicting_fs_entries.empty?
168
+ msg = "Export dir (#{export_dir}) not clean. Refusing to export. (Conflicting files: #{conflicting_fs_entries.join(', ')})"
169
+ raise ExportDirNotEmpty, msg
170
+ end
171
+ end
172
+
173
+ def force_export?
174
+ @force_export
175
+ end
176
+
177
+ def conflicting_fs_entries
178
+ Dir.glob(File.join(cookbooks_dir, "*")) +
179
+ Dir.glob(File.join(policyfiles_data_bag_dir, "*"))
180
+ end
181
+
182
+ def cookbooks_dir
183
+ File.join(export_dir, "cookbooks")
184
+ end
185
+
186
+ def policyfiles_data_bag_dir
187
+ File.join(export_dir, "data_bags", "policyfiles")
188
+ end
189
+
190
+ end
191
+
192
+ end
193
+ end
194
+
@@ -32,9 +32,11 @@ module ChefDK
32
32
 
33
33
  attr_reader :ui
34
34
  attr_reader :storage_config
35
+ attr_reader :overwrite
35
36
 
36
- def initialize(policyfile: nil, ui: nil, root_dir: nil)
37
+ def initialize(policyfile: nil, ui: nil, root_dir: nil, overwrite: false)
37
38
  @ui = ui
39
+ @overwrite = overwrite
38
40
 
39
41
  policyfile_rel_path = policyfile || "Policyfile.rb"
40
42
  policyfile_full_path = File.expand_path(policyfile_rel_path, root_dir)
@@ -51,7 +53,7 @@ module ChefDK
51
53
  raise PolicyfileNotFound, "Policyfile not found at path #{policyfile_expanded_path}"
52
54
  end
53
55
 
54
- if File.exist?(policyfile_lock_expanded_path)
56
+ if installing_from_lock?
55
57
  install_from_lock
56
58
  else
57
59
  generate_lock_and_install
@@ -113,6 +115,10 @@ module ChefDK
113
115
  raise PolicyfileInstallError.new("Failed to install cookbooks from lockfile", error)
114
116
  end
115
117
 
118
+ def installing_from_lock?
119
+ !@overwrite && File.exist?(policyfile_lock_expanded_path)
120
+ end
121
+
116
122
  end
117
123
  end
118
124
  end
@@ -63,7 +63,10 @@ module ChefDK
63
63
  end
64
64
 
65
65
  def uploader
66
- ChefDK::Policyfile::Uploader.new(policyfile_lock, policy_group, ui: ui, http_client: http_client)
66
+ ChefDK::Policyfile::Uploader.new(policyfile_lock, policy_group,
67
+ ui: ui,
68
+ http_client: http_client,
69
+ policy_document_native_api: config.policy_document_native_api)
67
70
  end
68
71
 
69
72
  def run
@@ -36,6 +36,9 @@ module ChefDK
36
36
  class LockfileNotFound < PolicyfileServiceError
37
37
  end
38
38
 
39
+ class ExportDirNotEmpty < PolicyfileServiceError
40
+ end
41
+
39
42
  class PolicyfileNestedException < PolicyfileServiceError
40
43
 
41
44
  attr_reader :cause
@@ -73,5 +76,8 @@ module ChefDK
73
76
  class PolicyfilePushError < PolicyfileNestedException
74
77
  end
75
78
 
79
+ class PolicyfileExportRepoError < PolicyfileNestedException
80
+ end
81
+
76
82
  end
77
83
 
@@ -1,3 +1,3 @@
1
- source "https://supermarket.getchef.com"
1
+ source "https://supermarket.chef.io"
2
2
 
3
3
  metadata
@@ -58,7 +58,7 @@ If you use the `ssl_cert` task, change the values in the `config/rake.rb` file a
58
58
 
59
59
  The second config file, `.chef/knife.rb` is a repository specific configuration file for knife. If you're using the Opscode Platform, you can download one for your organization from the management console. If you're using the Open Source Chef Server, you can generate a new one with `knife configure`. For more information about configuring Knife, see the Knife documentation.
60
60
 
61
- http://docs.opscode.com/knife.html
61
+ http://docs.chef.io/knife.html
62
62
 
63
63
  Next Steps
64
64
  ==========
@@ -33,7 +33,7 @@ The first and recommended method is to use a vendor branch if you're using Git.
33
33
 
34
34
  This will:
35
35
 
36
- * Download the cookbook tarball from cookbooks.opscode.com.
36
+ * Download the cookbook tarball from the Chef Supermarket.
37
37
  * Ensure its on the git master branch.
38
38
  * Checks for an existing vendor branch, and creates if it doesn't.
39
39
  * Checks out the vendor branch (chef-vendor-COOKBOOK).
@@ -1,5 +1,5 @@
1
1
  Requires Chef 0.10.0+.
2
2
 
3
- This directory is for Ruby DSL and JSON files for environments. For more information see the Chef wiki page:
3
+ This directory is for Ruby DSL and JSON files for environments. For more information see "About Environments" in the Chef documentation:
4
4
 
5
- http://wiki.opscode.com/display/chef/Environments
5
+ http://docs.chef.io/environments.html
@@ -0,0 +1,3 @@
1
+ require 'serverspec'
2
+
3
+ set :backend, :exec
@@ -1,8 +1,2 @@
1
1
  require 'chefspec'
2
-
3
- current_dir = File.dirname(__FILE__)
4
-
5
- RSpec.configure do |config|
6
- # Point to the cookbooks directory
7
- config.cookbook_path = File.join(current_dir, '../cookbooks')
8
- end
2
+ require 'chefspec/berkshelf'
@@ -1,6 +1,6 @@
1
1
  name 'code_generator'
2
2
  maintainer 'Chef Software, Inc.'
3
- maintainer_email 'dev@getchef.com'
3
+ maintainer_email 'dev@chef.io'
4
4
  license 'Apache 2 License'
5
5
  description 'Generates Chef code for Chef DK'
6
6
  long_description 'Generates Chef code for Chef DK'
@@ -18,6 +18,21 @@ template "#{app_dir}/.kitchen.yml" do
18
18
  helpers(ChefDK::Generator::TemplateHelper)
19
19
  end
20
20
 
21
+ directory "#{app_dir}/test/integration/default/serverspec" do
22
+ recursive true
23
+ end
24
+
25
+ cookbook_file "#{app_dir}/test/integration/default/serverspec/spec_helper.rb" do
26
+ source 'serverspec_spec_helper.rb'
27
+ action :create_if_missing
28
+ end
29
+
30
+ template "#{app_dir}/test/integration/default/serverspec/default_spec.rb" do
31
+ source 'serverspec_default_spec.rb.erb'
32
+ helpers(ChefDK::Generator::TemplateHelper)
33
+ action :create_if_missing
34
+ end
35
+
21
36
  # README
22
37
  template "#{app_dir}/README.md" do
23
38
  helpers(ChefDK::Generator::TemplateHelper)
@@ -47,8 +62,23 @@ cookbook_file "#{cookbook_dir}/Berksfile"
47
62
  directory "#{cookbook_dir}/recipes"
48
63
 
49
64
  template "#{cookbook_dir}/recipes/default.rb" do
50
- source "default_recipe.rb.erb"
65
+ source "recipe.rb.erb"
66
+ helpers(ChefDK::Generator::TemplateHelper)
67
+ end
68
+
69
+ # Chefspec
70
+ directory "#{cookbook_dir}/spec/unit/recipes" do
71
+ recursive true
72
+ end
73
+
74
+ cookbook_file "#{cookbook_dir}/spec/spec_helper.rb" do
75
+ action :create_if_missing
76
+ end
77
+
78
+ template "#{cookbook_dir}/spec/unit/recipes/default_spec.rb" do
79
+ source "recipe_spec.rb.erb"
51
80
  helpers(ChefDK::Generator::TemplateHelper)
81
+ action :create_if_missing
52
82
  end
53
83
 
54
84
  # git
@@ -25,19 +25,49 @@ cookbook_file "#{cookbook_dir}/Berksfile" do
25
25
  action :create_if_missing
26
26
  end
27
27
 
28
- # TK
28
+ # TK & Serverspec
29
29
  template "#{cookbook_dir}/.kitchen.yml" do
30
30
  source 'kitchen.yml.erb'
31
31
  helpers(ChefDK::Generator::TemplateHelper)
32
32
  action :create_if_missing
33
33
  end
34
34
 
35
+ directory "#{cookbook_dir}/test/integration/default/serverspec" do
36
+ recursive true
37
+ end
38
+
39
+ cookbook_file "#{cookbook_dir}/test/integration/default/serverspec/spec_helper.rb" do
40
+ source 'serverspec_spec_helper.rb'
41
+ action :create_if_missing
42
+ end
43
+
44
+ template "#{cookbook_dir}/test/integration/default/serverspec/default_spec.rb" do
45
+ source 'serverspec_default_spec.rb.erb'
46
+ helpers(ChefDK::Generator::TemplateHelper)
47
+ action :create_if_missing
48
+ end
49
+
50
+ # Chefspec
51
+ directory "#{cookbook_dir}/spec/unit/recipes" do
52
+ recursive true
53
+ end
54
+
55
+ cookbook_file "#{cookbook_dir}/spec/spec_helper.rb" do
56
+ action :create_if_missing
57
+ end
58
+
59
+ template "#{cookbook_dir}/spec/unit/recipes/default_spec.rb" do
60
+ source "recipe_spec.rb.erb"
61
+ helpers(ChefDK::Generator::TemplateHelper)
62
+ action :create_if_missing
63
+ end
64
+
35
65
  # Recipes
36
66
 
37
67
  directory "#{cookbook_dir}/recipes"
38
68
 
39
69
  template "#{cookbook_dir}/recipes/default.rb" do
40
- source "default_recipe.rb.erb"
70
+ source "recipe.rb.erb"
41
71
  helpers(ChefDK::Generator::TemplateHelper)
42
72
  action :create_if_missing
43
73
  end