From 16b24001f158b513070e5910aa634f879567a1c8 Mon Sep 17 00:00:00 2001 From: Oleksandr Chebotarov Date: Wed, 18 Dec 2024 16:12:00 +0200 Subject: [PATCH] misc: Prevent overriding set by test example aggregate_failures flag (#2975) ## Context Recently we're added by default `aggregate_failures: true` to all test's metadata. Unfortunately, `aggregate_failures` changes some information on the test example metadata and limits our opportunity to debug randomly failing test more efficiently. Particularly this overrides `example.exception`. It's needed when we have test that fails from time to time depending on some tricky data combination. The quickest and easiest known way to me to debug it is to use `after { |example| binding.pry if example.exception }`. That callback will trigger breakpoint only if test failed. quick debug setup will look like ```ruby describe "something" do after { |example| binding.pry if example.exception } 1000.times do fit "randomly failing test", aggregate_failures: false do # .... end end end ``` That will run the same test many times and trigger breakpoint only when it's worth to check by us. ## Description Adjusting metadata setup to respect values set directly on test. --- spec/spec_helper.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1f6f657ebd3..9d30fd9a600 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -66,6 +66,8 @@ end config.define_derived_metadata do |meta| - meta[:aggregate_failures] = true + unless meta.key?(:aggregate_failures) + meta[:aggregate_failures] = true + end end end