summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsnehaldwivedi <sdwivedi@msystechnologies.com>2021-06-16 05:29:17 -0700
committerMarc A. Paradise <marc.paradise@gmail.com>2022-05-24 15:25:14 -0400
commitcb0f07953e14bc4614beb90f69ba66483fea264c (patch)
treeb8512edcc8dda33ea927f7e4ab593d7324083260
parentf859ba08cc51f79d34928316d50df8a9b8f7af1f (diff)
downloadchef-cb0f07953e14bc4614beb90f69ba66483fea264c.tar.gz
Updated reviewd changes to add cookbook name in path in error msg
Signed-off-by: snehaldwivedi <sdwivedi@msystechnologies.com>
-rw-r--r--lib/chef/cookbook/syntax_check.rb2
-rw-r--r--spec/unit/cookbook/syntax_check_spec.rb2
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/chef/cookbook/syntax_check.rb b/lib/chef/cookbook/syntax_check.rb
index d94b7ed074..914e2947ca 100644
--- a/lib/chef/cookbook/syntax_check.rb
+++ b/lib/chef/cookbook/syntax_check.rb
@@ -248,7 +248,7 @@ class Chef
# Debugs ruby syntax errors by printing the path to the file and any
# diagnostic info given in +error_message+
def invalid_ruby_file(ruby_file, error_message)
- file_relative_path = File.basename(ruby_file)
+ file_relative_path = ruby_file[ruby_file.index(cookbook_path.split("/").last), ruby_file.length]
Chef::Log.fatal("Cookbook file #{file_relative_path} has a ruby syntax error.")
error_message.each_line { |l| Chef::Log.fatal(l.chomp) }
false
diff --git a/spec/unit/cookbook/syntax_check_spec.rb b/spec/unit/cookbook/syntax_check_spec.rb
index 88f0f102a7..8741c89bda 100644
--- a/spec/unit/cookbook/syntax_check_spec.rb
+++ b/spec/unit/cookbook/syntax_check_spec.rb
@@ -166,7 +166,7 @@ describe Chef::Cookbook::SyntaxCheck do
end
it "it indicates that a ruby file has a syntax error" do
- expect(Chef::Log).to receive(:fatal).with("Cookbook file default.rb has a ruby syntax error.")
+ expect(Chef::Log).to receive(:fatal).with("Cookbook file borken/recipes/default.rb has a ruby syntax error.")
allow(Chef::Log).to receive(:fatal)
expect(syntax_check.validate_ruby_files).to be_falsey
end