@@ -1342,13 +1342,18 @@ def extract_execution_results(group)
1342
1342
end
1343
1343
1344
1344
describe "#run" do
1345
- let ( :reporter ) { double ( "reporter" ) . as_null_object }
1346
1345
1347
- context "with fail_fast? => true " do
1346
+ context "with fail_fast and failures_required == 1 " do
1348
1347
let ( :group ) do
1349
- group = RSpec . describe
1350
- allow ( group ) . to receive ( :fail_fast? ) { true }
1351
- group
1348
+ the_group = RSpec . describe
1349
+ allow ( the_group ) . to receive ( :fail_fast? ) { true }
1350
+ the_group
1351
+ end
1352
+ let ( :config ) { Configuration . new }
1353
+ let ( :reporter ) do
1354
+ the_reporter = Reporter . new config
1355
+ allow ( the_reporter ) . to receive ( :failures_required ) { 1 }
1356
+ the_reporter
1352
1357
end
1353
1358
1354
1359
it "does not run examples after the failed example" do
@@ -1357,7 +1362,7 @@ def extract_execution_results(group)
1357
1362
self . group . example ( 'example 2' ) { examples_run << self ; fail ; }
1358
1363
self . group . example ( 'example 3' ) { examples_run << self }
1359
1364
1360
- self . group . run
1365
+ self . group . run ( reporter )
1361
1366
1362
1367
expect ( examples_run . length ) . to eq ( 2 )
1363
1368
end
@@ -1370,6 +1375,43 @@ def extract_execution_results(group)
1370
1375
end
1371
1376
end
1372
1377
1378
+ context "with fail_fast and failures_required = 3" do
1379
+ let ( :group ) do
1380
+ the_group = RSpec . describe
1381
+ allow ( the_group ) . to receive ( :fail_fast? ) { true }
1382
+ the_group
1383
+ end
1384
+ let ( :config ) { Configuration . new }
1385
+
1386
+ let ( :reporter ) do
1387
+ the_reporter = Reporter . new config
1388
+ allow ( the_reporter ) . to receive ( :failures_required ) { 3 }
1389
+ the_reporter
1390
+ end
1391
+
1392
+ it "does not run examples after 3 failed examples" do
1393
+ examples_run = [ ]
1394
+ self . group . example ( 'example 1' ) { examples_run << self }
1395
+ self . group . example ( 'example 2' ) { examples_run << self ; fail ; }
1396
+ self . group . example ( 'example 3' ) { examples_run << self ; fail ; }
1397
+ self . group . example ( 'example 4' ) { examples_run << self ; fail ; }
1398
+ self . group . example ( 'example 5' ) { examples_run << self }
1399
+
1400
+ self . group . run ( reporter )
1401
+
1402
+ expect ( examples_run . length ) . to eq ( 4 )
1403
+ end
1404
+
1405
+ it "sets RSpec.world.wants_to_quit flag if encountering an exception in before(:all)" do
1406
+ self . group . before ( :all ) { raise "error in before all" }
1407
+ self . group . example ( "equality" ) { expect ( 1 ) . to eq ( 2 ) }
1408
+ expect ( self . group . run ) . to be_falsey
1409
+ expect ( RSpec . world . wants_to_quit ) . to be_truthy
1410
+ end
1411
+ end
1412
+
1413
+ let ( :reporter ) { double ( "reporter" ) . as_null_object }
1414
+
1373
1415
context "with RSpec.world.wants_to_quit=true" do
1374
1416
let ( :group ) { RSpec . describe }
1375
1417
0 commit comments