summaryrefslogtreecommitdiff
path: root/chef/spec
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2012-10-25 16:12:45 -0700
committerdanielsdeleo <dan@opscode.com>2012-10-25 16:12:45 -0700
commit265a1b898c7235198d60b14d83b75754133b0884 (patch)
treeb7ade654e9c1ddd9100d2a56a73359414a6ff101 /chef/spec
parent06b4061054c2c1226cb1b0512e8e826ff1b721c9 (diff)
parent524860a0ad575af60169b4651d95c25dbb4d7a6e (diff)
downloadchef-265a1b898c7235198d60b14d83b75754133b0884.tar.gz
Merge branch 'CHEF-3561'
Diffstat (limited to 'chef/spec')
-rw-r--r--chef/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb32
1 files changed, 31 insertions, 1 deletions
diff --git a/chef/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb b/chef/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb
index 54a57d8077..52c719d2fb 100644
--- a/chef/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb
+++ b/chef/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb
@@ -34,7 +34,8 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do
before do
@description = Chef::Formatters::ErrorDescription.new("Error Converging Resource:")
- @outputter = Chef::Formatters::Outputter.new(StringIO.new, STDERR)
+ @stdout = StringIO.new
+ @outputter = Chef::Formatters::Outputter.new(@stdout, STDERR)
#@outputter = Chef::Formatters::Outputter.new(STDOUT, STDERR)
Chef::Config.stub!(:cookbook_path).and_return([ "/var/chef/cache" ])
@@ -77,6 +78,35 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do
@description.display(@outputter)
end
+ describe "and the error is a template error" do
+ before do
+ @description = Chef::Formatters::ErrorDescription.new("Error Converging Resource:")
+ @template_class = Class.new { include Chef::Mixin::Template }
+ @template = @template_class.new
+ @context = {:chef => "cool"}
+
+ @resource = template("/tmp/foo.txt") do
+ mode "0644"
+ end
+
+ @error = begin
+ @template.render_template("foo\nbar\nbaz\n<%= this_is_not_defined %>\nquin\nqunx\ndunno", @context) {|r| r}
+ rescue Chef::Mixin::Template::TemplateError => e
+ e
+ end
+
+ @inspector = Chef::Formatters::ErrorInspectors::ResourceFailureInspector.new(@resource, :create, @error)
+ @inspector.add_explanation(@description)
+ end
+
+ it "includes contextual info from the template error in the output" do
+ @description.display(@outputter)
+ @stdout.string.should include(@error.source_listing)
+ end
+
+
+ end
+
describe "recipe_snippet" do
before do
# fake code to run through #recipe_snippet