1
1
Feature : fail fast
2
2
3
- Use the `fail_fast` option to tell RSpec to abort the run on first failure :
3
+ Use the `fail_fast` option to tell RSpec to abort the run on after N failures :
4
4
5
- ```ruby
6
- RSpec.configure { |c| c.fail_fast = true }
7
- ```
8
-
9
- Background :
5
+ Scenario : `fail_fast` with no failures (runs all examples)
10
6
Given a file named "spec/spec_helper.rb" with:
11
7
"""ruby
12
- RSpec.configure {|c| c.fail_fast = true }
8
+ RSpec.configure {|c| c.fail_fast = 1 }
13
9
"""
14
-
15
- Scenario : `fail_fast` with no failures (runs all examples)
16
- Given a file named "spec/example_spec.rb" with:
10
+ And a file named "spec/example_spec.rb" with:
17
11
"""ruby
18
12
RSpec.describe "something" do
19
13
it "passes" do
@@ -27,7 +21,11 @@ Feature: fail fast
27
21
Then the examples should all pass
28
22
29
23
Scenario : `fail_fast` with first example failing (only runs the one example)
30
- Given a file named "spec/example_spec.rb" with:
24
+ Given a file named "spec/spec_helper.rb" with:
25
+ """ruby
26
+ RSpec.configure {|c| c.fail_fast = 1}
27
+ """
28
+ And a file named "spec/example_spec.rb" with:
31
29
"""ruby
32
30
require "spec_helper"
33
31
RSpec.describe "something" do
@@ -43,7 +41,11 @@ Feature: fail fast
43
41
Then the output should contain "1 example, 1 failure"
44
42
45
43
Scenario : `fail_fast` with multiple files, second example failing (only runs the first two examples)
46
- Given a file named "spec/example_1_spec.rb" with:
44
+ Given a file named "spec/spec_helper.rb" with:
45
+ """ruby
46
+ RSpec.configure {|c| c.fail_fast = 1}
47
+ """
48
+ And a file named "spec/example_1_spec.rb" with:
47
49
"""ruby
48
50
require "spec_helper"
49
51
RSpec.describe "something" do
@@ -77,3 +79,31 @@ Feature: fail fast
77
79
"""
78
80
When I run `rspec spec`
79
81
Then the output should contain "2 examples, 1 failure"
82
+
83
+
84
+ Scenario : `fail_fast 2` with 1st and 3rd examples failing (only runs the first 3 examples)
85
+ Given a file named "spec/spec_helper.rb" with:
86
+ """ruby
87
+ RSpec.configure {|c| c.fail_fast = 2}
88
+ """
89
+ And a file named "spec/example_spec.rb" with:
90
+ """ruby
91
+ require "spec_helper"
92
+ RSpec.describe "something" do
93
+ it "fails once" do
94
+ fail
95
+ end
96
+
97
+ it "passes once" do
98
+ end
99
+
100
+ it "fails twice" do
101
+ fail
102
+ end
103
+
104
+ it "passes" do
105
+ end
106
+ end
107
+ """
108
+ When I run `rspec spec/example_spec.rb -fd`
109
+ Then the output should contain "3 examples, 2 failures"
0 commit comments