File: exit_status.feature

package info (click to toggle)
ruby-rspec 3.13.0c0e0m0s1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,856 kB
  • sloc: ruby: 70,868; sh: 1,423; makefile: 99
file content (66 lines) | stat: -rw-r--r-- 1,925 bytes parent folder | download | duplicates (6)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Feature: `--failure-exit-code` option (exit status)

  The `rspec` command exits with an exit status of 0 if all examples pass, and 1
  if any examples fail. The failure exit code can be overridden using the
  `--failure-exit-code` option.

  Scenario: A passing spec with the default exit code
    Given a file named "ok_spec.rb" with:
      """ruby
      RSpec.describe "ok" do
        it "passes" do
        end
      end
      """
    When I run `rspec ok_spec.rb`
    Then the exit status should be 0
    And the examples should all pass

  Scenario: A failing spec with the default exit code
    Given a file named "ko_spec.rb" with:
      """ruby
      RSpec.describe "KO" do
        it "fails" do
          raise "KO"
        end
      end
      """
    When I run `rspec ko_spec.rb`
    Then the exit status should be 1
    And the output should contain "1 example, 1 failure"

  Scenario: A nested failing spec with the default exit code
    Given a file named "nested_ko_spec.rb" with:
      """ruby
      RSpec.describe "KO" do
        describe "nested" do
          it "fails" do
            raise "KO"
          end
        end
      end
      """
    When I run `rspec nested_ko_spec.rb`
    Then the exit status should be 1
    And the output should contain "1 example, 1 failure"

  Scenario: Exit with 0 when no examples are run
    Given a file named "a_no_examples_spec.rb" with:
      """ruby
      """
    When I run `rspec a_no_examples_spec.rb`
    Then the exit status should be 0
    And the output should contain "0 examples"

  Scenario: A failing spec and `--failure-exit-code` is 42
    Given a file named "ko_spec.rb" with:
      """ruby
      RSpec.describe "KO" do
        it "fails" do
          raise "KO"
        end
      end
      """
    When I run `rspec --failure-exit-code 42 ko_spec.rb`
    Then the exit status should be 42
    And the output should contain "1 example, 1 failure"