Class: Philiprehberger::HttpMock::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/philiprehberger/http_mock/request.rb

Overview

Represents a recorded HTTP request

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method:, url:, headers: {}, body: nil) ⇒ Request

Returns a new instance of Request.

Parameters:

  • method (Symbol)

    the HTTP method

  • url (String)

    the request URL

  • headers (Hash) (defaults to: {})

    the request headers

  • body (String, nil) (defaults to: nil)

    the request body



23
24
25
26
27
28
# File 'lib/philiprehberger/http_mock/request.rb', line 23

def initialize(method:, url:, headers: {}, body: nil)
  @method = method
  @url = url
  @headers = headers
  @body = body
end

Instance Attribute Details

#bodyString? (readonly)

Returns the request body.

Returns:

  • (String, nil)

    the request body



17
18
19
# File 'lib/philiprehberger/http_mock/request.rb', line 17

def body
  @body
end

#headersHash (readonly)

Returns the request headers.

Returns:

  • (Hash)

    the request headers



14
15
16
# File 'lib/philiprehberger/http_mock/request.rb', line 14

def headers
  @headers
end

#methodSymbol (readonly)

Returns the HTTP method (:get, :post, etc.).

Returns:

  • (Symbol)

    the HTTP method (:get, :post, etc.)



8
9
10
# File 'lib/philiprehberger/http_mock/request.rb', line 8

def method
  @method
end

#urlString (readonly)

Returns the request URL.

Returns:

  • (String)

    the request URL



11
12
13
# File 'lib/philiprehberger/http_mock/request.rb', line 11

def url
  @url
end