Class: SpecForge::Forge::Runner
- Inherits:
-
Object
- Object
- SpecForge::Forge::Runner
- Defined in:
- lib/spec_forge/forge/runner.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
Executes expectations using RSpec as the underlying test framework
Runner wraps RSpec to run individual expectation blocks, capturing results and formatting them for display. It creates isolated RSpec example groups for each expectation.
Defined Under Namespace
Classes: ArrayIO, ContentValidator, HeaderValidator, Reporter, SchemaValidator
Instance Attribute Summary collapse
-
#error_io ⇒ StringIO
readonly
Error stream for RSpec formatter.
-
#output_io ⇒ ArrayIO
readonly
Output stream for RSpec formatter.
Instance Method Summary collapse
-
#initialize(cli_args = []) ⇒ Runner
constructor
Creates a new RSpec runner with the specified CLI arguments.
-
#run(forge, step, expectation) ⇒ Array<Hash>
Runs an expectation and returns any failed examples.
Constructor Details
#initialize(cli_args = []) ⇒ Runner
Creates a new RSpec runner with the specified CLI arguments
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/spec_forge/forge/runner.rb', line 26 def initialize(cli_args = []) = RSpec::Core::ConfigurationOptions.new(cli_args) @configuration = RSpec.configuration.deep_dup @configuration.reset @world = RSpec::Core::World.new @runner = RSpec::Core::Runner.new(, @configuration, @world) @output_io = ArrayIO.new @error_io = StringIO.new @runner.configure(@error_io, @output_io) end |
Instance Attribute Details
#error_io ⇒ StringIO (readonly)
Returns Error stream for RSpec formatter.
17 18 19 |
# File 'lib/spec_forge/forge/runner.rb', line 17 def error_io @error_io end |
#output_io ⇒ ArrayIO (readonly)
Returns Output stream for RSpec formatter.
14 15 16 |
# File 'lib/spec_forge/forge/runner.rb', line 14 def output_io @output_io end |
Instance Method Details
#run(forge, step, expectation) ⇒ Array<Hash>
Runs an expectation and returns any failed examples
49 50 51 52 53 54 55 56 |
# File 'lib/spec_forge/forge/runner.rb', line 49 def run(forge, step, expectation) configure_formatters(forge) @runner.run_specs([create_example_group(forge, step, expectation)]) entry = @output_io.entries.last.to_h entry[:examples].reject { |ex| ex[:status] == "passed" } end |