Backtrace is incorrectly cleaned when RSpec is installed in the current working directory
Created by: tomstuart
TL;DR: RSpec’s backtrace cleaner used to remove all RSpec-related lines from the backtrace, but as of 3.0.0.beta1 it no longer does.
I have BUNDLE_PATH
set to .bundle/gems
, so when I run bundle install
, RSpec gets installed in .bundle
inside my project’s working directory. Pre-3.0.0.beta1, the RSpec-related lines would be cleaned from a backtrace whenever my specs raised an exception, but as of 3.0.0.beta1 they aren’t, because those lines mention files in the current working directory.
A related problem was first raised in #798 (closed), which resulted in the backtrace cleaner being introduced in #843. At the time, @myronmarston commented:
there's a way of using bundler (that I personally recommend) that causes all gems to be installed in a subdirectory of your project root...which means that the change here will cause backtraces to always contain all lines from all gems for folks who use bundler like I do. That's bad.
The simplest fix I can think of is to only default
backtrace_inclusion_patterns
to the current directory if it's really needed, i.e. if the current directory matches any of the exclusion patterns
This was the solution that #843 eventually used, and everything worked fine until @dchelimsky committed af0b271c a few months later, which cleaned up the backtrace formatting logic to unconditionally include all lines from the working directory regardless of exclusion patterns.
So right now I must set config.backtrace_inclusion_patterns = []
in every RSpec 3 project to avoid my backtraces being hopelessly noisy. I’d rather not do this.
Although I haven’t noticed other gems cluttering up my backtrace, I think my problem with RSpec-related lines is a special case of gem-related lines appearing in backtraces.
(This is a pull request (vs an issue) so that I can include a failing test. My test directly contradicts this one, so I can’t simply make it pass.)