Class: SpecForge::Forge::Request

Inherits:
Action
  • Object
show all
Defined in:
lib/spec_forge/forge/actions/request.rb

Overview

Action for the request: step attribute

Builds and executes an HTTP request based on the step's configuration, then stores both the request and response in the forge's variables for use by subsequent actions.

Instance Attribute Summary

Attributes inherited from Action

#step

Instance Method Summary collapse

Methods inherited from Action

#initialize

Constructor Details

This class inherits a constructor from SpecForge::Forge::Action

Instance Method Details

#run(forge) ⇒ void

This method returns an undefined value.

Executes the HTTP request and stores the response

Parameters:

  • forge (Forge)

    The forge instance



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/spec_forge/forge/actions/request.rb', line 20

def run(forge)
  sendable_request, resolved_request = build_requests

  forge.display.action(
    "#{sendable_request.http_verb} #{sendable_request.url}",
    symbol: :right_arrow, symbol_styles: :yellow
  )

  response = forge.http_client.perform(sendable_request)
  response = parse_response(response)

  # Only store the original resolved request before we modify it
  forge.variables[:request] = resolved_request
  forge.variables[:response] = response
end