Class: HttpStub::Configurer::Request::Stub

Inherits:
Net::HTTP::Post
  • Object
show all
Defined in:
lib/http_stub/configurer/request/stub.rb

Instance Method Summary collapse

Constructor Details

#initialize(uri, args) ⇒ Stub

Returns a new instance of Stub.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/http_stub/configurer/request/stub.rb', line 7

def initialize(uri, args)
  super("/stubs")
  self.content_type = "application/json"
  self.body = {
      "uri" => HttpStub::Configurer::Request::ControllableValue.format(uri),
      "method" => args[:method],
      "headers" => HttpStub::Configurer::Request::ControllableValue.format(args[:headers] || {}),
      "parameters" => HttpStub::Configurer::Request::ControllableValue.format(args[:parameters] || {}),
      "response" => {
          "status" => args[:response][:status] || "",
          "headers" => args[:response][:headers] || {},
          "body" => args[:response][:body],
          "delay_in_seconds" => args[:response][:delay_in_seconds] || ""
      }
  }.to_json
end