summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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