File: backtrace_filtering.feature

package info (click to toggle)
ruby-rspec-rails 7.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,796 kB
  • sloc: ruby: 11,068; sh: 198; makefile: 6
file content (47 lines) | stat: -rw-r--r-- 1,244 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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 "actionpack"

  Scenario: Using `rspec --backtrace`
    When I run `rspec --backtrace`
    Then the output should contain "1 example, 1 failure"
    And the output should contain "actionpack"