Class: Inferno::DSL::HTTPClientBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/inferno/dsl/http_client_builder.rb

Overview

This module contains the HTTP DSL available to test writers.

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



47
48
49
50
51
# File 'lib/inferno/dsl/http_client_builder.rb', line 47

def method_missing(name, *args, &)
  return runnable.send(name, *args, &) if runnable.respond_to? name

  super
end

Instance Attribute Details

#runnableObject

Returns the value of attribute runnable.



7
8
9
# File 'lib/inferno/dsl/http_client_builder.rb', line 7

def runnable
  @runnable
end

Instance Method Details

#headers(headers = nil) ⇒ void

This method returns an undefined value.

Define custom headers for a client

Parameters:

  • headers (Hash) (defaults to: nil)


42
43
44
# File 'lib/inferno/dsl/http_client_builder.rb', line 42

def headers(headers = nil)
  @headers ||= headers
end

#url(url = nil) ⇒ void

This method returns an undefined value.

Define the base url for an HTTP client. A string or symbol can be provided. A string is interpreted as a url. A symbol is interpreted as the name of an input to the Runnable.

Parameters:

  • url (String, Symbol) (defaults to: nil)


29
30
31
32
33
34
35
36
# File 'lib/inferno/dsl/http_client_builder.rb', line 29

def url(url = nil)
  @url ||=
    if url.is_a? Symbol
      runnable.send(url)
    else
      url
    end
end