chef 10.16.0 → 10.16.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/distro/common/html/chef-client.8.html +3 -3
  2. data/distro/common/html/chef-expander.8.html +3 -3
  3. data/distro/common/html/chef-expanderctl.8.html +3 -3
  4. data/distro/common/html/chef-server-webui.8.html +3 -3
  5. data/distro/common/html/chef-server.8.html +3 -3
  6. data/distro/common/html/chef-solo.8.html +3 -3
  7. data/distro/common/html/chef-solr.8.html +3 -3
  8. data/distro/common/html/knife-bootstrap.1.html +3 -3
  9. data/distro/common/html/knife-client.1.html +4 -4
  10. data/distro/common/html/knife-configure.1.html +4 -4
  11. data/distro/common/html/knife-cookbook-site.1.html +3 -3
  12. data/distro/common/html/knife-cookbook.1.html +3 -3
  13. data/distro/common/html/knife-data-bag.1.html +3 -3
  14. data/distro/common/html/knife-environment.1.html +6 -6
  15. data/distro/common/html/knife-exec.1.html +4 -4
  16. data/distro/common/html/knife-index.1.html +4 -4
  17. data/distro/common/html/knife-node.1.html +4 -4
  18. data/distro/common/html/knife-role.1.html +6 -6
  19. data/distro/common/html/knife-search.1.html +3 -3
  20. data/distro/common/html/knife-ssh.1.html +3 -3
  21. data/distro/common/html/knife-status.1.html +3 -3
  22. data/distro/common/html/knife-tag.1.html +3 -3
  23. data/distro/common/html/knife.1.html +0 -320
  24. data/distro/common/html/shef.1.html +3 -3
  25. data/distro/common/man/man1/knife-bootstrap.1 +1 -1
  26. data/distro/common/man/man1/knife-client.1 +1 -1
  27. data/distro/common/man/man1/knife-configure.1 +1 -1
  28. data/distro/common/man/man1/knife-cookbook-site.1 +1 -1
  29. data/distro/common/man/man1/knife-cookbook.1 +1 -1
  30. data/distro/common/man/man1/knife-data-bag.1 +1 -1
  31. data/distro/common/man/man1/knife-environment.1 +1 -1
  32. data/distro/common/man/man1/knife-exec.1 +1 -1
  33. data/distro/common/man/man1/knife-index.1 +1 -1
  34. data/distro/common/man/man1/knife-node.1 +1 -1
  35. data/distro/common/man/man1/knife-role.1 +1 -1
  36. data/distro/common/man/man1/knife-search.1 +1 -1
  37. data/distro/common/man/man1/knife-ssh.1 +1 -1
  38. data/distro/common/man/man1/knife-status.1 +1 -1
  39. data/distro/common/man/man1/knife-tag.1 +1 -1
  40. data/distro/common/man/man1/knife.1 +1 -1
  41. data/distro/common/man/man1/shef.1 +1 -1
  42. data/distro/common/man/man8/chef-client.8 +1 -1
  43. data/distro/common/man/man8/chef-expander.8 +1 -1
  44. data/distro/common/man/man8/chef-expanderctl.8 +1 -1
  45. data/distro/common/man/man8/chef-server-webui.8 +1 -1
  46. data/distro/common/man/man8/chef-server.8 +1 -1
  47. data/distro/common/man/man8/chef-solo.8 +1 -1
  48. data/distro/common/man/man8/chef-solr.8 +1 -1
  49. data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +6 -0
  50. data/lib/chef/knife/cookbook_site_install.rb +10 -1
  51. data/lib/chef/provider/cookbook_file.rb +0 -3
  52. data/lib/chef/provider/file.rb +21 -4
  53. data/lib/chef/provider/remote_directory.rb +24 -15
  54. data/lib/chef/version.rb +1 -1
  55. data/spec/functional/resource/cookbook_file_spec.rb +51 -0
  56. data/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +31 -1
  57. data/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb +2 -0
  58. data/spec/unit/provider/directory_spec.rb +72 -66
  59. data/spec/unit/provider/file_spec.rb +72 -66
  60. data/spec/unit/provider/remote_directory_spec.rb +7 -0
  61. metadata +5 -4
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "KNIFE\-COOKBOOK" "1" "October 2012" "Chef 10.16.0" "Chef Manual"
4
+ .TH "KNIFE\-COOKBOOK" "1" "October 2012" "Chef 10.16.2" "Chef Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBknife\-cookbook\fR \- upload and manage chef cookbooks
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "KNIFE\-DATA\-BAG" "1" "October 2012" "Chef 10.16.0" "Chef Manual"
4
+ .TH "KNIFE\-DATA\-BAG" "1" "October 2012" "Chef 10.16.2" "Chef Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBknife\-data\-bag\fR \- Store arbitrary data on a Chef Server
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "KNIFE\-ENVIRONMENT" "1" "October 2012" "Chef 10.16.0" "Chef Manual"
4
+ .TH "KNIFE\-ENVIRONMENT" "1" "October 2012" "Chef 10.16.2" "Chef Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBknife\-environment\fR \- Define cookbook policies for the environments in your infrastructure
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "KNIFE\-EXEC" "1" "October 2012" "Chef 10.16.0" "Chef Manual"
4
+ .TH "KNIFE\-EXEC" "1" "October 2012" "Chef 10.16.2" "Chef Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBknife\-exec\fR \- Run user scripts using the Chef API DSL
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "KNIFE\-INDEX" "1" "October 2012" "Chef 10.16.0" "Chef Manual"
4
+ .TH "KNIFE\-INDEX" "1" "October 2012" "Chef 10.16.2" "Chef Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBknife\-index\fR \- Rebuild the search index on a Chef Server
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "KNIFE\-NODE" "1" "October 2012" "Chef 10.16.0" "Chef Manual"
4
+ .TH "KNIFE\-NODE" "1" "October 2012" "Chef 10.16.2" "Chef Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBknife\-node\fR \- Manage the hosts in your infrastructure
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "KNIFE\-ROLE" "1" "October 2012" "Chef 10.16.0" "Chef Manual"
4
+ .TH "KNIFE\-ROLE" "1" "October 2012" "Chef 10.16.2" "Chef Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBknife\-role\fR \- Group common configuration settings
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "KNIFE\-SEARCH" "1" "October 2012" "Chef 10.16.0" "Chef Manual"
4
+ .TH "KNIFE\-SEARCH" "1" "October 2012" "Chef 10.16.2" "Chef Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBknife\-search\fR \- Find objects on a Chef Server by query
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "KNIFE\-SSH" "1" "October 2012" "Chef 10.16.0" "Chef Manual"
4
+ .TH "KNIFE\-SSH" "1" "October 2012" "Chef 10.16.2" "Chef Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBknife\-ssh\fR \- Run a command or interactive session on multiple remote hosts
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "KNIFE\-STATUS" "1" "October 2012" "Chef 10.16.0" "Chef Manual"
4
+ .TH "KNIFE\-STATUS" "1" "October 2012" "Chef 10.16.2" "Chef Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBknife\-status\fR \- Display status information for the nodes in your infrastructure
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "KNIFE\-TAG" "1" "October 2012" "Chef 10.16.0" "Chef Manual"
4
+ .TH "KNIFE\-TAG" "1" "October 2012" "Chef 10.16.2" "Chef Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBknife\-tag\fR \- Apply tags to nodes on a Chef Server
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "KNIFE" "1" "October 2012" "Chef 10.16.0" "Chef Manual"
4
+ .TH "KNIFE" "1" "October 2012" "Chef 10.16.2" "Chef Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBknife\fR \- Chef Server API client utility
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "SHEF" "1" "October 2012" "Chef 10.16.0" "Chef Manual"
4
+ .TH "SHEF" "1" "October 2012" "Chef 10.16.2" "Chef Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBshef\fR \- Interactive Chef Console
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "CHEF\-CLIENT" "8" "October 2012" "Chef 10.16.0" "Chef Manual"
4
+ .TH "CHEF\-CLIENT" "8" "October 2012" "Chef 10.16.2" "Chef Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBchef\-client\fR \- Runs a client node connecting to a chef\-server\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "CHEF\-EXPANDER" "8" "October 2012" "Chef 10.16.0" "Chef Manual"
4
+ .TH "CHEF\-EXPANDER" "8" "October 2012" "Chef 10.16.2" "Chef Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBchef\-expander\fR \- fetches messages from RabbitMQ, processes, and loads into chef\-solr
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "CHEF\-EXPANDERCTL" "8" "October 2012" "Chef 10.16.0" "Chef Manual"
4
+ .TH "CHEF\-EXPANDERCTL" "8" "October 2012" "Chef 10.16.2" "Chef Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBchef\-expanderctl\fR \- management program for chef\-expander
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "CHEF\-SERVER\-WEBUI" "8" "October 2012" "Chef 10.16.0" "Chef Manual"
4
+ .TH "CHEF\-SERVER\-WEBUI" "8" "October 2012" "Chef 10.16.2" "Chef Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBchef\-server\-webui\fR \- Start the Chef Server merb application slice providing Web User Interface (Management Console)\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "CHEF\-SERVER" "8" "October 2012" "Chef 10.16.0" "Chef Manual"
4
+ .TH "CHEF\-SERVER" "8" "October 2012" "Chef 10.16.2" "Chef Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBchef\-server\fR \- Start the Chef Server merb application slice\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "CHEF\-SOLO" "8" "October 2012" "Chef 10.16.0" "Chef Manual"
4
+ .TH "CHEF\-SOLO" "8" "October 2012" "Chef 10.16.2" "Chef Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBchef\-solo\fR \- Runs chef in solo mode against a specified cookbook location\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "CHEF\-SOLR" "8" "October 2012" "Chef 10.16.0" "Chef Manual"
4
+ .TH "CHEF\-SOLR" "8" "October 2012" "Chef 10.16.2" "Chef Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBchef\-solr\fR \- Runs as Chef\'s search server
@@ -44,6 +44,12 @@ class Chef
44
44
  end
45
45
 
46
46
  error_description.section("Compiled Resource:", "#{resource.to_text}")
47
+
48
+ # Template errors get wrapped in an exception class that can show the relevant template code,
49
+ # so add them to the error output.
50
+ if exception.respond_to?(:source_listing)
51
+ error_description.section("Template Context:", "#{exception.source_location}\n#{exception.source_listing}")
52
+ end
47
53
  end
48
54
 
49
55
  def recipe_snippet
@@ -107,6 +107,7 @@ class Chef
107
107
  end
108
108
  end
109
109
 
110
+
110
111
  unless config[:no_deps]
111
112
  md = Chef::Cookbook::Metadata.new
112
113
  md.from_file(File.join(@install_path, @cookbook_name, "metadata.rb"))
@@ -143,13 +144,21 @@ class Chef
143
144
 
144
145
  def extract_cookbook(upstream_file, version)
145
146
  ui.info("Uncompressing #{@cookbook_name} version #{version}.")
146
- shell_out!("tar zxvf #{Shellwords.escape upstream_file}", :cwd => @install_path)
147
+ shell_out!("tar zxvf #{convert_path upstream_file}", :cwd => @install_path)
147
148
  end
148
149
 
149
150
  def clear_existing_files(cookbook_path)
150
151
  ui.info("Removing pre-existing version.")
151
152
  FileUtils.rmtree(cookbook_path) if File.directory?(cookbook_path)
152
153
  end
154
+
155
+ def convert_path(upstream_file)
156
+ if ENV['MSYSTEM'] == 'MINGW32'
157
+ return upstream_file.sub(/^([[:alpha:]]):/, '/\1')
158
+ else
159
+ return Shellwords.escape upstream_file
160
+ end
161
+ end
153
162
  end
154
163
  end
155
164
  end
@@ -44,9 +44,6 @@ class Chef
44
44
  Chef::Log.debug("#{@new_resource} staging #{file_cache_location} to #{tempfile.path}")
45
45
  tempfile.close
46
46
  FileUtils.cp(file_cache_location, tempfile.path)
47
- # Since the @new_resource.path file will not be updated
48
- # at the time of converge, we must use the tempfile
49
- update_new_file_state(tempfile.path)
50
47
  end
51
48
  Chef::Log.info("#{@new_resource} created file #{@new_resource.path}")
52
49
  end
@@ -132,7 +132,9 @@ class Chef
132
132
  @current_resource.path(@new_resource.path)
133
133
  if !::File.directory?(@new_resource.path)
134
134
  if ::File.exist?(@new_resource.path)
135
- @current_resource.checksum(checksum(@new_resource.path))
135
+ if @action != :create_if_missing
136
+ @current_resource.checksum(checksum(@new_resource.path))
137
+ end
136
138
  end
137
139
  end
138
140
  load_current_resource_attrs
@@ -142,6 +144,13 @@ class Chef
142
144
  end
143
145
 
144
146
  def load_current_resource_attrs
147
+ if Chef::Platform.windows?
148
+ # TODO: To work around CHEF-3554, add support for Windows
149
+ # equivalent, or implicit resource reporting won't work for
150
+ # Windows.
151
+ return
152
+ end
153
+
145
154
  if ::File.exist?(@new_resource.path)
146
155
  stat = ::File.stat(@new_resource.path)
147
156
  @current_resource.owner(stat.uid)
@@ -215,13 +224,21 @@ class Chef
215
224
  # override the default with the tempfile, since the
216
225
  # file at @new_resource.path will not be updated on converge
217
226
  def update_new_file_state(path=@new_resource.path)
227
+ if !::File.directory?(path)
228
+ @new_resource.checksum(checksum(path))
229
+ end
230
+
231
+ if Chef::Platform.windows?
232
+ # TODO: To work around CHEF-3554, add support for Windows
233
+ # equivalent, or implicit resource reporting won't work for
234
+ # Windows.
235
+ return
236
+ end
237
+
218
238
  stat = ::File.stat(path)
219
239
  @new_resource.owner(stat.uid)
220
240
  @new_resource.mode(stat.mode & 07777)
221
241
  @new_resource.group(stat.gid)
222
- if !::File.directory?(path)
223
- @new_resource.checksum(checksum(path))
224
- end
225
242
  end
226
243
 
227
244
  def action_create
@@ -34,23 +34,27 @@ class Chef
34
34
 
35
35
  def action_create
36
36
  super
37
-
38
- files_to_purge = Set.new(
39
- Dir.glob(::File.join(@new_resource.path, '**', '*'), ::File::FNM_DOTMATCH).select do |name|
40
- name !~ /(?:^|#{Regexp.escape(::File::SEPARATOR)})\.\.?$/
41
- end
42
- )
43
- files_to_transfer.each do |cookbook_file_relative_path|
44
- create_cookbook_file(cookbook_file_relative_path)
45
- # the file is removed from the purge list
46
- files_to_purge.delete(::File.join(@new_resource.path, cookbook_file_relative_path))
47
- # parent directories are also removed from the purge list
48
- directories=::File.dirname(::File.join(@new_resource.path, cookbook_file_relative_path)).split(::File::SEPARATOR)
49
- for i in 0..directories.length-1
50
- files_to_purge.delete(::File.join(directories[0..i]))
37
+ files_to_purge = Set.new(Dir.glob(::File.join(@new_resource.path, '**', '*'),
38
+ ::File::FNM_DOTMATCH).select do |name|
39
+ name !~ /(?:^|#{Regexp.escape(::File::SEPARATOR)})\.\.?$/
40
+ end)
41
+
42
+ converge_by("Create managed files in directory") do
43
+ files_to_transfer.each do |cookbook_file_relative_path|
44
+ create_cookbook_file(cookbook_file_relative_path)
45
+ # the file is removed from the purge list
46
+ files_to_purge.delete(::File.join(@new_resource.path, cookbook_file_relative_path))
47
+ # parent directories are also removed from the purge list
48
+ directories=::File.dirname(::File.join(@new_resource.path, cookbook_file_relative_path)).split(::File::SEPARATOR)
49
+ for i in 0..directories.length-1
50
+ files_to_purge.delete(::File.join(directories[0..i]))
51
+ end
51
52
  end
52
53
  end
53
- purge_unmanaged_files(files_to_purge)
54
+
55
+ converge_by("Purge unmanaged files from directory") do
56
+ purge_unmanaged_files(files_to_purge)
57
+ end
54
58
  end
55
59
 
56
60
  def action_create_if_missing
@@ -170,5 +174,10 @@ class Chef
170
174
  end
171
175
 
172
176
  end
177
+
178
+ def whyrun_supported?
179
+ true
180
+ end
181
+
173
182
  end
174
183
  end
@@ -17,7 +17,7 @@
17
17
 
18
18
  class Chef
19
19
  CHEF_ROOT = File.dirname(File.expand_path(File.dirname(__FILE__)))
20
- VERSION = '10.16.0'
20
+ VERSION = '10.16.2'
21
21
  end
22
22
 
23
23
  # NOTE: the Chef::Version class is defined in version_class.rb
@@ -0,0 +1,51 @@
1
+ #
2
+ # Author:: Tim Hinderliter (<tim@opscode.com>)
3
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'spec_helper'
20
+
21
+ describe Chef::Resource::CookbookFile do
22
+ include_context Chef::Resource::File
23
+
24
+ let(:file_base) { 'cookbook_file_spec' }
25
+ let(:source) { 'java.response' }
26
+ let(:cookbook_name) { 'java' }
27
+ let(:expected_content) { IO.read(File.join(CHEF_SPEC_DATA, 'cookbooks', 'java', 'files', 'default', 'java.response')) }
28
+
29
+ def create_resource
30
+ # set up cookbook collection for this run to use, based on our
31
+ # spec data.
32
+ cookbook_repo = File.expand_path(File.join(CHEF_SPEC_DATA, 'cookbooks'))
33
+ Chef::Cookbook::FileVendor.on_create { |manifest| Chef::Cookbook::FileSystemFileVendor.new(manifest, cookbook_repo) }
34
+ cookbook_collection = Chef::CookbookCollection.new(Chef::CookbookLoader.new(cookbook_repo))
35
+
36
+ node = Chef::Node.new
37
+ events = Chef::EventDispatch::Dispatcher.new
38
+ run_context = Chef::RunContext.new(node, cookbook_collection, events)
39
+ resource = Chef::Resource::CookbookFile.new(path, run_context)
40
+ resource.cookbook(cookbook_name)
41
+ resource.source(source)
42
+
43
+ resource
44
+ end
45
+
46
+ let!(:resource) do
47
+ create_resource
48
+ end
49
+
50
+ it_behaves_like "a file resource"
51
+ end
@@ -34,7 +34,8 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do
34
34
 
35
35
  before do
36
36
  @description = Chef::Formatters::ErrorDescription.new("Error Converging Resource:")
37
- @outputter = Chef::Formatters::Outputter.new(StringIO.new, STDERR)
37
+ @stdout = StringIO.new
38
+ @outputter = Chef::Formatters::Outputter.new(@stdout, STDERR)
38
39
  #@outputter = Chef::Formatters::Outputter.new(STDOUT, STDERR)
39
40
 
40
41
  Chef::Config.stub!(:cookbook_path).and_return([ "/var/chef/cache" ])
@@ -77,6 +78,35 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do
77
78
  @description.display(@outputter)
78
79
  end
79
80
 
81
+ describe "and the error is a template error" do
82
+ before do
83
+ @description = Chef::Formatters::ErrorDescription.new("Error Converging Resource:")
84
+ @template_class = Class.new { include Chef::Mixin::Template }
85
+ @template = @template_class.new
86
+ @context = {:chef => "cool"}
87
+
88
+ @resource = template("/tmp/foo.txt") do
89
+ mode "0644"
90
+ end
91
+
92
+ @error = begin
93
+ @template.render_template("foo\nbar\nbaz\n<%= this_is_not_defined %>\nquin\nqunx\ndunno", @context) {|r| r}
94
+ rescue Chef::Mixin::Template::TemplateError => e
95
+ e
96
+ end
97
+
98
+ @inspector = Chef::Formatters::ErrorInspectors::ResourceFailureInspector.new(@resource, :create, @error)
99
+ @inspector.add_explanation(@description)
100
+ end
101
+
102
+ it "includes contextual info from the template error in the output" do
103
+ @description.display(@outputter)
104
+ @stdout.string.should include(@error.source_listing)
105
+ end
106
+
107
+
108
+ end
109
+
80
110
  describe "recipe_snippet" do
81
111
  before do
82
112
  # fake code to run through #recipe_snippet