|
1 | 1 | Feature: Excluding lines from the backtrace
|
2 | 2 |
|
3 |
| - To reduce the noise when diagnosing failures, RSpec excludes matching lines |
4 |
| - from backtraces. The default exclusion patterns are: |
| 3 | + To reduce the noise when diagnosing failures, RSpec can exclude lines |
| 4 | + belonging to certain gems or matching given patterns. |
5 | 5 |
|
| 6 | + If you want to filter out backtrace lines belonging to specific gems, you can |
| 7 | + use `config.filter_gems_from_backtrace` like so: |
| 8 | + ```ruby |
| 9 | + config.filter_gems_from_backtrace "ignored_gem", "another_ignored_gem", |
| 10 | + ``` |
| 11 | + |
| 12 | + For more control over which lines to ignore, you can use the the |
| 13 | + `backtrace_exclusion_patterns` option to either replace the default exclusion |
| 14 | + patterns, or append your own, e.g. |
| 15 | + ```ruby |
| 16 | + config.backtrace_exclusion_patterns = [/first pattern/, /second pattern/] |
| 17 | + config.backtrace_exclusion_patterns << /another pattern/ |
| 18 | + ``` |
| 19 | +
|
| 20 | + The default exclusion patterns are: |
6 | 21 | ```ruby
|
7 | 22 | /\/lib\d*\/ruby\//,
|
8 | 23 | /org\/jruby\//,
|
9 | 24 | /bin\//,
|
10 | 25 | /lib\/rspec\/(core|expectations|matchers|mocks)/
|
11 | 26 | ```
|
12 | 27 |
|
13 |
| - This list can be modified or replaced with the `backtrace_exclusion_patterns` |
14 |
| - option. Additionally, `rspec` can be run with the `--backtrace` option to skip |
| 28 | + Additionally, `rspec` can be run with the `--backtrace` option to skip |
15 | 29 | backtrace cleaning entirely.
|
16 | 30 |
|
17 |
| - In addition, if you want to filter out backtrace lines from specific gems, you |
18 |
| - can use `config.filter_gems_from_backtrace`. |
19 |
| - |
20 | 31 | Scenario: Using default `backtrace_exclusion_patterns`
|
21 | 32 | Given a file named "spec/failing_spec.rb" with:
|
22 | 33 | """ruby
|
|
0 commit comments