Skip to content

A platform for community discussion. Free, open, simple.

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

Martin Brennan42d203d7736b
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index 6bd575fe359..df77ca52296 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -695,7 +695,12 @@ RSpec.configure do |config|
lines << "\n"
lines << "Error encountered while proccessing #{path}"
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
lines << "~~~~~~~ END SERVER EXCEPTIONS ~~~~~~~"