Class: Coatepec::Spec::FlakyChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/coatepec/spec/flaky_checker.rb

Overview

Runs a spec selection multiple times, each round with an independently random seed (RSpec's --seed N is equivalent to --order rand:N, confirmed against rspec-core's own option_parser.rb), and groups per-example pass/fail status across rounds by the example's own id -- stable regardless of execution order, since it's derived from declaration position/nesting, not from --order. Composes Runner unchanged, exactly like FactoryProfRunner: every round is a plain, ordinary Runner#run call with a different seed, no strategy override needed (unlike FactoryProfRunner, this feature has no load-time activation trick to fight -- see docs/superpowers/specs/2026-08-13-flaky-spec-detection-design.md).

Constant Summary collapse

DEFAULT_RUNS =
5
MAX_TOTAL_SECONDS =

timeout_seconds * runs must not exceed this

1800
MAX_ITEMS =

same bound rails_model/FactoryProfRunner use elsewhere

200

Instance Method Summary collapse

Constructor Details

#initialize(project_root, rails_runtime: nil) ⇒ FlakyChecker

Returns a new instance of FlakyChecker.



23
24
25
# File 'lib/coatepec/spec/flaky_checker.rb', line 23

def initialize(project_root, rails_runtime: nil)
  @runner = Runner.new(project_root, rails_runtime: rails_runtime)
end

Instance Method Details

#call(paths:, example: nil, timeout_seconds: Runner::DEFAULT_TIMEOUT, runs: DEFAULT_RUNS) ⇒ Object



27
28
29
30
31
# File 'lib/coatepec/spec/flaky_checker.rb', line 27

def call(paths:, example: nil, timeout_seconds: Runner::DEFAULT_TIMEOUT, runs: DEFAULT_RUNS)
  validate_budget!(timeout_seconds, runs)
  rounds = Array.new(runs) { run_one_round(paths, example, timeout_seconds) }
  build_report(rounds)
end