summaryrefslogtreecommitdiff
path: root/spec/unit/formatters/error_inspectors
diff options
context:
space:
mode:
authorMartin Smith <martin@mbs3.org>2015-08-06 10:51:53 -0500
committerMartin Smith <martin@mbs3.org>2015-08-06 10:51:53 -0500
commit3060794742d90b0d8cef8f21bddce4a330b97153 (patch)
tree50d941127a52d1c5dac446038e70177cf0c22cef /spec/unit/formatters/error_inspectors
parent3cb1dd2b59a5c2a32db24287cb8bf43b6d3357e4 (diff)
downloadchef-3060794742d90b0d8cef8f21bddce4a330b97153.tar.gz
Add additional helpful section for frozen objects
Augument runtime errors with additional information that explains why an object might be frozen, and how frozen resource properties are a good thing. Fixes #3734, for [accepted RFC 55](https://github.com/chef/chef-rfc/pull/135).
Diffstat (limited to 'spec/unit/formatters/error_inspectors')
-rw-r--r--spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb
index 5f95beb259..3c8d5dfa29 100644
--- a/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb
@@ -110,6 +110,32 @@ describe Chef::Formatters::ErrorInspectors::CompileErrorInspector do
end
end
+ context "when the error is a RuntimeError about frozen object" do
+ let(:exception) do
+ e = RuntimeError.new("can't modify frozen Array")
+ e.set_backtrace(trace)
+ e
+ end
+
+ let(:path_to_failed_file) { "/tmp/kitchen/cache/cookbooks/foo/recipes/default.rb" }
+
+ let(:trace) do
+ [
+ "/tmp/kitchen/cache/cookbooks/foo/recipes/default.rb:2:in `block in from_file'",
+ "/tmp/kitchen/cache/cookbooks/foo/recipes/default.rb:1:in `from_file'"
+ ]
+ end
+
+ describe "when explaining a runtime error in the compile phase" do
+ it "correctly detects RuntimeError for frozen objects" do
+ expect(inspector.exception_message_modifying_frozen?).to be(true)
+ end
+
+ # could also test for description.section to be called, but would have
+ # to adjust every other test to begin using a test double for description
+ end
+ end
+
context "when the error does not contain any lines from cookbooks" do
let(:trace) do