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, options) ⇒ 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, options)
  super("/stubs")
  self.content_type = "application/json"
  self.body = {
      "uri" => HttpStub::Configurer::Request::ControllableValue.format(uri),
      "method" => options[:method],
      "headers" => HttpStub::Configurer::Request::ControllableValue.format(options[:headers] || {}),
      "parameters" => HttpStub::Configurer::Request::ControllableValue.format(options[:parameters] || {}),
      "response" => {
          "status" => options[:response][:status] || "",
          "content_type" => options[:response][:content_type] || "application/json",
          "body" => options[:response][:body],
          "delay_in_seconds" => options[:response][:delay_in_seconds] || ""
      }
  }.to_json
end