Class: SpecForge::Documentation::Builder::Extractor
- Inherits:
-
Object
- Object
- SpecForge::Documentation::Builder::Extractor
- Defined in:
- lib/spec_forge/documentation/builder/extractor.rb
Overview
Extracts endpoint data from a test execution context
The Extractor takes a Forge::Context from a completed test step and extracts all relevant request and response data needed for API documentation generation.
Instance Method Summary collapse
-
#extract_endpoint ⇒ Hash
Extracts endpoint data from the context.
-
#initialize(context) ⇒ Extractor
constructor
Creates a new Extractor instance.
Constructor Details
#initialize(context) ⇒ Extractor
Creates a new Extractor instance
27 28 29 30 31 |
# File 'lib/spec_forge/documentation/builder/extractor.rb', line 27 def initialize(context) @context = context @step = context.step @variables = context.variables end |
Instance Method Details
#extract_endpoint ⇒ Hash
Extracts endpoint data from the context
Pulls request and response information from the context variables and organizes it into a hash structure for documentation.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/spec_forge/documentation/builder/extractor.rb', line 51 def extract_endpoint request = @variables[:request] response = @variables[:response] headers = request[:headers] { # Request data base_url: request[:base_url], url: request[:url], http_verb: request[:http_verb], content_type: headers["content-type"], request_body: request[:body], request_headers: headers.except("content-type"), request_query: request[:query], # Response data response_status: response[:status], response_body: response[:body], response_headers: response[:headers] } end |