@@ -319,6 +319,57 @@ module RSpec::Core
319
319
expect ( filters ) . to eq ( [ ] )
320
320
end
321
321
322
+ it "runs :all|:context hooks even if there are no unskipped examples in that context" do
323
+ filters = [ ]
324
+ group = RSpec . describe ( "un-skipped describe" ) do
325
+ before ( :all ) { filters << "before all in group" }
326
+ after ( :all ) { filters << "after all in group" }
327
+
328
+ xcontext ( "skipped context" ) do
329
+ before ( :context ) { filters << "before context in group" }
330
+ after ( :context ) { filters << "after context in group" }
331
+
332
+ it ( "is skipped" ) { }
333
+ end
334
+ end
335
+ group . run
336
+ expect ( filters ) . to eq ( [ "before all in group" , "after all in group" ] )
337
+ end
338
+
339
+ it "does not run :all|:context hooks in global config if the entire context is skipped" do
340
+ filters = [ ]
341
+ RSpec . configure do |c |
342
+ c . before ( :all ) { filters << "before all in config" }
343
+ c . after ( :all ) { filters << "after all in config" }
344
+ c . before ( :context ) { filters << "before context in config" }
345
+ c . after ( :context ) { filters << "after context in config" }
346
+ end
347
+ group = RSpec . xdescribe ( "skipped describe" ) do
348
+ context ( "skipped context" ) do
349
+ it ( "is skipped" ) { }
350
+ end
351
+ end
352
+ group . run
353
+ expect ( filters ) . to eq ( [ ] )
354
+ end
355
+
356
+ it "does not run local :all|:context hooks if the entire context is skipped" do
357
+ filters = [ ]
358
+ group = RSpec . xdescribe ( "skipped describe" ) do
359
+ before ( :all ) { filters << "before all in group" }
360
+ after ( :all ) { filters << "after all in group" }
361
+
362
+ context ( "skipped context" ) do
363
+ before ( :context ) { filters << "before context in group" }
364
+ after ( :context ) { filters << "after context in group" }
365
+
366
+ it ( "is skipped" ) { }
367
+ end
368
+ end
369
+ group . run
370
+ expect ( filters ) . to eq ( [ ] )
371
+ end
372
+
322
373
context "when the hook filters apply to individual examples instead of example groups" do
323
374
let ( :each_filters ) { [ ] }
324
375
let ( :all_filters ) { [ ] }
0 commit comments