Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to add rails gems to exclusion filters
Rails in backtraces can get quite spammy, and the configuration option to `filter_gems_from_backtrace` is not well-known since it is not found in the generator's `rails_helper.rb`. This adds `filter_rails_from_backtrace!` as a convenience method for nixing rails gems in the backtrace and adds it to `rails_helper.rb` to raise awareness.
- Loading branch information
1 parent
819a697
commit 570911a
Showing
6 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
Feature: backtrace filtering | ||
|
||
The following configuration setting will filter out lines in backtraces that come from Rails gems in order to reduce the noise in test failure output: | ||
|
||
```ruby | ||
RSpec.configure do |config| | ||
config.filter_rails_from_backtrace! | ||
end | ||
``` | ||
|
||
`rspec` will always show the full backtrace output when run with the `--backtrace` commandline option. | ||
|
||
Background: Using `filter_rails_from_backtrace!` | ||
Given a file named "spec/failing_spec.rb" with: | ||
"""ruby | ||
require "rails_helper" | ||
RSpec.configure do |config| | ||
config.filter_rails_from_backtrace! | ||
end | ||
RSpec.describe "Controller", :type => :controller do | ||
controller do | ||
def index | ||
raise "Something went wrong." | ||
end | ||
end | ||
describe "GET index" do | ||
it "raises an error" do | ||
get :index | ||
end | ||
end | ||
end | ||
""" | ||
|
||
Scenario: Using the bare `rspec` command | ||
When I run `rspec` | ||
Then the output should contain "1 example, 1 failure" | ||
And the output should not contain "activesupport" | ||
|
||
Scenario: Using `rspec --backtrace` | ||
When I run `rspec --backtrace` | ||
Then the output should contain "1 example, 1 failure" | ||
And the output should contain "activesupport" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters