Don't report broken absolute path when app_root is nil

When running tests that does not initialize rails (e.g. `rake test` under
active_model), it used to just cut off the leading "/" from absolte paths and
report something like

rails test Users/a_matsuda/rails/activemodel/test/cases/api_test.rb:40

that cannot be executed.
This commit is contained in:
Akira Matsuda 2023-01-03 11:57:14 +09:00
parent f517eefe14
commit 6287c109d3
No known key found for this signature in database
1 changed files with 5 additions and 1 deletions

View File

@ -52,7 +52,11 @@ module Rails
end
def relative_path_for(file)
file.sub(/^#{app_root}\/?/, "")
if app_root
file.sub(/^#{app_root}\/?/, "")
else
file
end
end
private