Class: Seams::CLI::TestChanged
- Inherits:
-
Object
- Object
- Seams::CLI::TestChanged
- Defined in:
- lib/seams/cli/test_changed.rb
Overview
Runs RSpec for every engine that has changed against the merge base with ‘main` (or another base via the `base:` keyword). Falls back to “run every engine’s specs” when the merge base cannot be resolved (CI on a shallow clone, no git, etc) — better to over-run than to silently skip.
bin/rails seams:test:changed # base = main
bin/rails seams:test:changed BASE=develop
Returns true when every engine spec run passed; false otherwise. The caller (rake task or bin/seams) translates that to an exit code.
Constant Summary collapse
- DEFAULT_BASE =
"main"- DEFAULT_ENGINES_ROOT =
"engines"
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(base: DEFAULT_BASE, engines_root: DEFAULT_ENGINES_ROOT, output: $stdout) ⇒ TestChanged
constructor
A new instance of TestChanged.
Constructor Details
#initialize(base: DEFAULT_BASE, engines_root: DEFAULT_ENGINES_ROOT, output: $stdout) ⇒ TestChanged
Returns a new instance of TestChanged.
23 24 25 26 27 |
# File 'lib/seams/cli/test_changed.rb', line 23 def initialize(base: DEFAULT_BASE, engines_root: DEFAULT_ENGINES_ROOT, output: $stdout) @base = base @engines_root = engines_root @output = output end |
Instance Method Details
#call ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/seams/cli/test_changed.rb', line 29 def call engines = changed_engines if engines.empty? @output.puts("seams:test:changed — no engines changed since #{@base}; skipping.") return true end @output.puts("seams:test:changed — running specs for #{engines.size} engine(s):") engines.each { |name| @output.puts(" - #{name}") } @output.puts("") failed = engines.reject { |name| run_engine_specs(name) } if failed.empty? @output.puts("All affected engine specs passed.") true else @output.puts("Failed engines: #{failed.join(", ")}") false end end |