If you ever have an error in rspec and the backtrace doesn’t show the line of code that actually threw the error (eg it’s deep inside rails), run rspec with the `—backtrace` flag. That will run the code without backtrace silencers and reveal the true source of the error

@iainbeeston I had to use that recently. I wish there was an option to filter to show only from your code down, ie: showing the framework frames called by your code, as opposed to those calling your code, as normally I’m not interested in the high-level frames, like those from Rack

@pablobm yeah it’s a very blunt tool - it also turns regular rspec failures into big backtraces that come up from the intervals of rspec (because I think expectation failures are implemented as errors internally?)

@iainbeeston @pablobm they are indeed. An alternative approach is to surround the problematic call in the RSpec example with begin/rescue/end block, and manually print out the backtrace, which I do with `pp $!.backtrace`

@iainbeeston Oh: and don't forget to re-raise or you may get a passing example where you shouldn't have one!

· · Web · 0 · 0 · 0
Sign in to participate in the conversation
NI Tech

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!