Generalize VCR testing infrastructure for user workflows

Aperta
#835 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

  • #857 di @mathiusj — chiusa senza merge

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
ruby

Direzione di ricerca

Inizia da docs/TESTING_GENERALIZATION_PLAN.md, quindi esamina test/examples/support/functional_test.rb e test/test_helper.rb per comprendere la configurazione VCR esistente e il comportamento della sandbox. Confronta questi dettagli con l’obiettivo della Fase 1, incluso l’helper pubblico, il supporto opzionale per VCR, la documentazione e i test di esempio annotati; il lavoro è completo quando gli utenti possono testare workflow arbitrari senza credenziali reali.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

Context

The VCR testing infrastructure was successfully implemented for the examples tests in PR #655. Currently, it lives entirely within Roast's internal test suite (test/examples/support/functional_test.rb under the Examples::FunctionalTest namespace) and is only usable for testing the built-in examples.

Sam's ask: "now that you have the VCR tests merged, I think another high impact item related to that would be to generalize the system so anybody can use it to write tests for their roast workflows, not just our examples."

A planning doc already exists at docs/TESTING_GENERALIZATION_PLAN.md with detailed implementation steps.

Goal

Make it easy for anyone to write reliable, fast tests for their Roast workflows without needing real API credentials or incurring costs.

What Needs to Change

Current State
  • Examples::FunctionalTest is a private test base class in test/examples/support/
  • VCR config is hardcoded in test/test_helper.rb (cassette dir, fake credentials, base URL)
  • in_sandbox copies examples/ directory — not useful for external workflows
  • VCR and WebMock are dev-only dependencies (require: false)
  • No lib/roast/testing/ exists — zero public test helpers
  • No documentation on testing workflows
Target State
  • Public Roast::Testing::WorkflowTest base class users can inherit from
  • Configurable VCR setup (cassette dir, credentials, base URL)
  • in_sandbox works with any workflow directory, not just examples/
  • VCR is optional (graceful degradation when not installed)
  • Clear documentation and annotated example tests

Implementation Plan

Phase 1: Minimal Viable Version
  1. Extract test helper to public API — Move FunctionalTest to lib/roast/testing/workflow_test.rb as Roast::Testing::WorkflowTest, parameterize hardcoded paths
  2. Make VCR optional — Runtime check with defined?(VCR), graceful fallback for users without it
  3. Write testing documentation — docs/TESTING.md with quick start, recording, assertions, troubleshooting
  4. Add annotated example test — examples/test/ showing real test patterns
Phase 2: Polish
  1. Generator command — roast test:init to scaffold test boilerplate (test_helper.rb, example test, cassette dir, .gitignore)

User Experience Target

require "roast/testing/workflow_test"

class MyWorkflowTest < Roast::Testing::WorkflowTest
  test "my workflow produces expected output" do
    stdout, stderr = in_sandbox :my_workflow do
      Roast::Workflow.from_file("path/to/my_workflow.rb", params)
    end
    assert_empty stderr
    assert_includes stdout, "expected output"
  end
end

Recording: RECORD_VCR=true bundle exec ruby test/my_workflow_test.rb
Replay: bundle exec ruby test/my_workflow_test.rb

Open Questions

  • Naming: Roast::Testing::WorkflowTest vs Roast::TestHelper vs Roast::WorkflowTestCase?
  • Should VCR config be provided via a DSL method or class-level config?
  • Should we support RSpec in addition to Minitest?
  • Should roast test:init be part of Phase 1?

Related

  • PR #655: VCR infrastructure for examples (merged)
  • PR #582: Template shorthand syntax (merged)
  • docs/TESTING_GENERALIZATION_PLAN.md: Existing planning document
  • Issue #570: DSL migration and testing improvements
Lingua principale
Ruby
Stelle
1.3k
Fork
80
Merge medio
21m
PR unite (30g)
3

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Shopify/roast

Tutte le issue di Shopify/roast

Issue simili

Altre issue su Ruby

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.