rspec-core icon indicating copy to clipboard operation
rspec-core copied to clipboard

Debugging output for example to give full context

Open cheerfulstoic opened this issue 5 years ago • 5 comments

Sorry if this already exists, but I honestly wasn't sure how to search for it. I was actually a bit surprised when I went to create this issue because the most recent #2615 addressed it from a different angle.

Also, this is mainly to get an understanding of what you as the maintainers think of the idea. If it's something you're interested in I could potentially help with a PR.

Basically my thought was that people often have trouble debugging RSpec examples because the context for the example (the befores and the lets and the subjects etc...) may be in other parts of the file. Also, if you use nested describe/context blocks, it can get harder to figure out which ones apply.

All of this can be managed to some extent by careful design of the tests and only extracting logic from the example itself some of the time. Some people advocate for DAMP / having the full setup/exercise/expectation/teardown inside of the example. I can see the advantages of this, but it can also be harder to scan and maintain those tests.

My thought was: For any given example RSpec is keeping track of what context applies for an example (again before / let / subject / etc...). I was wondering if it would be difficult to have all of those lines outputted in a sort of "debug" format mode. This would preserve the advantages of having somewhat DRYer setup with the ability to see the context of each example along with the examples in the output.

Is this crazy? Does it already exist? If not, do you think it would be difficult? Thank you for your time and thanks for rspec.

cheerfulstoic avatar Apr 11 '19 06:04 cheerfulstoic