Debian Codegraph @

rspec-core/features/command_line/exit_status.feature

raw
1 Feature: `--failure-exit-code` option (exit status)
2
3 The `rspec` command exits with an exit status of 0 if all examples pass, and 1
4 if any examples fail. The failure exit code can be overridden using the
5 `--failure-exit-code` option.
6
7 Scenario: A passing spec with the default exit code
8 Given a file named "ok_spec.rb" with:
9 """ruby
10 RSpec.describe "ok" do
11 it "passes" do
12 end
13 end
14 """
15 When I run `rspec ok_spec.rb`
16 Then the exit status should be 0
17 And the examples should all pass
18
19 Scenario: A failing spec with the default exit code
20 Given a file named "ko_spec.rb" with:
21 """ruby
22 RSpec.describe "KO" do
23 it "fails" do
24 raise "KO"
25 end
26 end
27 """
28 When I run `rspec ko_spec.rb`
29 Then the exit status should be 1
30 And the output should contain "1 example, 1 failure"
31
32 Scenario: A nested failing spec with the default exit code
33 Given a file named "nested_ko_spec.rb" with:
34 """ruby
35 RSpec.describe "KO" do
36 describe "nested" do
37 it "fails" do
38 raise "KO"
39 end
40 end
41 end
42 """
43 When I run `rspec nested_ko_spec.rb`
44 Then the exit status should be 1
45 And the output should contain "1 example, 1 failure"
46
47 Scenario: Exit with 0 when no examples are run
48 Given a file named "a_no_examples_spec.rb" with:
49 """ruby
50 """
51 When I run `rspec a_no_examples_spec.rb`
52 Then the exit status should be 0
53 And the output should contain "0 examples"
54
55 Scenario: A failing spec and `--failure-exit-code` is 42
56 Given a file named "ko_spec.rb" with:
57 """ruby
58 RSpec.describe "KO" do
59 it "fails" do
60 raise "KO"
61 end
62 end
63 """
64 When I run `rspec --failure-exit-code 42 ko_spec.rb`
65 Then the exit status should be 42
66 And the output should contain "1 example, 1 failure"