DEV: Add ENV var to skip verbose gem backtrace in rspec failure (#25921)

In rspec request specs, we do a huge verbose backtrace
when there is an error. However, 99% of the time you don't
care about pages and pages of activesupport/rspec gem
LOC in the backtrace...so this commit introduces an
env var RSPEC_EXCLUDE_GEMS_IN_BACKTRACE to allow for
turning this off.
This commit is contained in:
Martin Brennan 2024-02-28 12:31:12 +10:00 committed by GitHub
parent 9e9673fac5
commit 42d203d773
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 1 deletions

View File

@ -695,7 +695,12 @@ RSpec.configure do |config|
lines << "\n" lines << "\n"
lines << "Error encountered while proccessing #{path}" lines << "Error encountered while proccessing #{path}"
lines << " #{ex.class}: #{ex.message}" lines << " #{ex.class}: #{ex.message}"
ex.backtrace.each { |line| lines << " #{line}\n" } ex.backtrace.each_with_index do |line, backtrace_index|
if ENV["RSPEC_EXCLUDE_GEMS_IN_BACKTRACE"]
next if line.match?(%r{/gems/})
end
lines << " #{line}\n"
end
end end
lines << "~~~~~~~ END SERVER EXCEPTIONS ~~~~~~~" lines << "~~~~~~~ END SERVER EXCEPTIONS ~~~~~~~"