Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 2c1cd3d

Browse files
jackscottiJack Scotti
authored andcommitted
Update fail-fast integration tests
1 parent 55f2e23 commit 2c1cd3d

File tree

2 files changed

+63
-16
lines changed

2 files changed

+63
-16
lines changed

features/command_line/fail_fast.feature

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,29 @@ Feature: `--fail-fast` option
33
Use the `--fail-fast` option to tell RSpec to stop running the test suite on
44
the first failed test.
55

6-
You may also specify `--no-fail-fast` to turn it off (default behaviour).
6+
You may add a parameter to tell RSpec to stop running the test suite after N
7+
failed tests, for example: `--fail-fast=3`.
8+
9+
You can also specify `--no-fail-fast` to turn it off (default behaviour).
710

811
Background:
912
Given a file named "fail_fast_spec.rb" with:
1013
"""ruby
1114
RSpec.describe "fail fast" do
1215
it "passing test" do; end
13-
it "failing test" do
16+
it "1st failing test" do
17+
fail
18+
end
19+
it "2nd failing test" do
20+
fail
21+
end
22+
it "3rd failing test" do
1423
fail
1524
end
16-
it "this should not be run" do; end
25+
it "4th failing test" do
26+
fail
27+
end
28+
it "passing test" do; end
1729
end
1830
"""
1931

@@ -22,6 +34,11 @@ Feature: `--fail-fast` option
2234
Then the output should contain ".F"
2335
Then the output should not contain ".F."
2436

37+
Scenario: Using `--fail-fast=3`
38+
When I run `rspec . --fail-fast=3`
39+
Then the output should contain ".FFF"
40+
Then the output should not contain ".FFFF."
41+
2542
Scenario: Using `--no-fail-fast`
2643
When I run `rspec . --no-fail-fast`
27-
Then the output should contain ".F."
44+
Then the output should contain ".FFFF."

features/configuration/fail_fast.feature

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
Feature: fail fast
22

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:
44

5-
```ruby
6-
RSpec.configure { |c| c.fail_fast = true }
7-
```
8-
9-
Background:
5+
Scenario: `fail_fast` with no failures (runs all examples)
106
Given a file named "spec/spec_helper.rb" with:
117
"""ruby
12-
RSpec.configure {|c| c.fail_fast = true}
8+
RSpec.configure {|c| c.fail_fast = 1}
139
"""
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:
1711
"""ruby
1812
RSpec.describe "something" do
1913
it "passes" do
@@ -27,7 +21,11 @@ Feature: fail fast
2721
Then the examples should all pass
2822

2923
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:
3129
"""ruby
3230
require "spec_helper"
3331
RSpec.describe "something" do
@@ -43,7 +41,11 @@ Feature: fail fast
4341
Then the output should contain "1 example, 1 failure"
4442

4543
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:
4749
"""ruby
4850
require "spec_helper"
4951
RSpec.describe "something" do
@@ -77,3 +79,31 @@ Feature: fail fast
7779
"""
7880
When I run `rspec spec`
7981
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

Comments
 (0)