Class: SpecForge::Forge
- Inherits:
-
Object
- Object
- SpecForge::Forge
- Defined in:
- lib/spec_forge/forge.rb,
lib/spec_forge/forge/hooks.rb,
lib/spec_forge/forge/timer.rb,
lib/spec_forge/forge/action.rb,
lib/spec_forge/forge/runner.rb,
lib/spec_forge/forge/context.rb,
lib/spec_forge/forge/display.rb,
lib/spec_forge/forge/callbacks.rb,
lib/spec_forge/forge/variables.rb,
lib/spec_forge/forge/actions/call.rb,
lib/spec_forge/forge/actions/debug.rb,
lib/spec_forge/forge/actions/store.rb,
lib/spec_forge/forge/actions/expect.rb,
lib/spec_forge/forge/actions/request.rb,
lib/spec_forge/forge/runner/array_io.rb,
lib/spec_forge/forge/runner/reporter.rb,
lib/spec_forge/forge/runner/header_validator.rb,
lib/spec_forge/forge/runner/schema_validator.rb,
lib/spec_forge/forge/runner/content_validator.rb
Overview
The main execution engine for running blueprints
Forge orchestrates the execution of blueprints by managing the execution context, HTTP client, variable storage, and display output. It processes each step sequentially and tracks statistics across the run.
Defined Under Namespace
Classes: Action, Call, Callbacks, Context, Debug, Display, Expect, Hooks, Request, Runner, Store, Timer, Variables
Instance Attribute Summary collapse
-
#blueprints ⇒ Array<Blueprint>
readonly
The blueprints being executed.
-
#callbacks ⇒ Callbacks
readonly
Callback registry for this forge run.
-
#display ⇒ Display
readonly
Display handler for output formatting.
-
#failures ⇒ Array<Hash>
readonly
List of failed expectations.
-
#hooks ⇒ Hash{Symbol => Array<Step::Call>}
readonly
Forge-level before and after hooks.
-
#http_client ⇒ HTTP::Client
readonly
HTTP client for making requests.
-
#runner ⇒ Runner
readonly
RSpec runner for executing expectations.
-
#stats ⇒ Hash
readonly
Statistics about the current run.
-
#timer ⇒ Timer
readonly
Timer for tracking execution duration.
-
#variables ⇒ Variables
readonly
Variable storage for the current run.
Class Method Summary collapse
-
.context ⇒ Context?
Returns the current execution context for the current thread.
-
.ignite ⇒ Class
Initializes SpecForge by loading the forge_helper and factories.
-
.run(blueprints) ⇒ void
Creates and runs a new Forge instance with the given blueprints.
-
.with_context(context) { ... } ⇒ Object
Executes a block with a given context.
Instance Method Summary collapse
-
#initialize(blueprints, verbosity_level: 0, hooks: {}) ⇒ Forge
constructor
Creates a new Forge instance with the specified blueprints.
-
#run ⇒ void
Executes all blueprints and their steps.
Constructor Details
#initialize(blueprints, verbosity_level: 0, hooks: {}) ⇒ Forge
Creates a new Forge instance with the specified blueprints
117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/spec_forge/forge.rb', line 117 def initialize(blueprints, verbosity_level: 0, hooks: {}) @blueprints = blueprints @callbacks = Callbacks.new @display = Display.new(verbosity_level:) @failures = [] @hooks = Step::Call.wrap_hooks(hooks) @http_client = HTTP::Client.new @runner = Runner.new @stats = {} @timer = Timer.new @variables = Variables.new(static: SpecForge.configuration.global_variables) reset_stats end |
Instance Attribute Details
#blueprints ⇒ Array<Blueprint> (readonly)
Returns The blueprints being executed.
79 80 81 |
# File 'lib/spec_forge/forge.rb', line 79 def blueprints @blueprints end |
#callbacks ⇒ Callbacks (readonly)
Returns Callback registry for this forge run.
82 83 84 |
# File 'lib/spec_forge/forge.rb', line 82 def callbacks @callbacks end |
#display ⇒ Display (readonly)
Returns Display handler for output formatting.
85 86 87 |
# File 'lib/spec_forge/forge.rb', line 85 def display @display end |
#failures ⇒ Array<Hash> (readonly)
Returns List of failed expectations.
88 89 90 |
# File 'lib/spec_forge/forge.rb', line 88 def failures @failures end |
#hooks ⇒ Hash{Symbol => Array<Step::Call>} (readonly)
Returns Forge-level before and after hooks.
91 92 93 |
# File 'lib/spec_forge/forge.rb', line 91 def hooks @hooks end |
#http_client ⇒ HTTP::Client (readonly)
Returns HTTP client for making requests.
94 95 96 |
# File 'lib/spec_forge/forge.rb', line 94 def http_client @http_client end |
#runner ⇒ Runner (readonly)
Returns RSpec runner for executing expectations.
97 98 99 |
# File 'lib/spec_forge/forge.rb', line 97 def runner @runner end |
#stats ⇒ Hash (readonly)
Returns Statistics about the current run.
100 101 102 |
# File 'lib/spec_forge/forge.rb', line 100 def stats @stats end |
#timer ⇒ Timer (readonly)
Returns Timer for tracking execution duration.
103 104 105 |
# File 'lib/spec_forge/forge.rb', line 103 def timer @timer end |
#variables ⇒ Variables (readonly)
Returns Variable storage for the current run.
106 107 108 |
# File 'lib/spec_forge/forge.rb', line 106 def variables @variables end |
Class Method Details
.context ⇒ Context?
Returns the current execution context for the current thread
44 45 46 |
# File 'lib/spec_forge/forge.rb', line 44 def context Thread.current[:spec_forge_context] end |
.ignite ⇒ Class
Initializes SpecForge by loading the forge_helper and factories
18 19 20 21 22 23 24 |
# File 'lib/spec_forge/forge.rb', line 18 def ignite load_forge_helper Factory.load_and_register # Return for chaining self end |
.run(blueprints) ⇒ void
This method returns an undefined value.
Creates and runs a new Forge instance with the given blueprints
35 36 37 |
# File 'lib/spec_forge/forge.rb', line 35 def run(blueprints, **) new(blueprints, **).run end |
.with_context(context) { ... } ⇒ Object
Executes a block with a given context
57 58 59 60 61 62 63 |
# File 'lib/spec_forge/forge.rb', line 57 def with_context(context) old_context = Thread.current[:spec_forge_context] Thread.current[:spec_forge_context] = context yield ensure Thread.current[:spec_forge_context] = old_context end |
Instance Method Details
#run ⇒ void
This method returns an undefined value.
Executes all blueprints and their steps
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/spec_forge/forge.rb', line 137 def run context = Context.new(variables:) Forge.with_context(context) do forge_start @blueprints.each do |blueprint| blueprint_start(blueprint) blueprint.steps.each do |step| step_start(blueprint, step) step_action(blueprint, step) step_end(blueprint, step) rescue => e step_end(blueprint, step, error: e) break end blueprint_end(blueprint) end ensure forge_end end end |