Module: Cucumber::Http::Request

Defined in:
lib/cucumber/http/world_extensions/request.rb

Instance Method Summary collapse

Instance Method Details

#clear_requestObject



39
40
41
# File 'lib/cucumber/http/world_extensions/request.rb', line 39

def clear_request
  request.clear
end

#perform_request(method, path) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cucumber/http/world_extensions/request.rb', line 14

def perform_request(method, path)
  add_header('params', parameters)

  begin
    r = RestClient::Request.execute(
      method: method.downcase,
      url: path,
      headers: headers,
      payload: payload
    )
  rescue RestClient::Exception => e
    r = e.response
  end

  set_request('url', path)
  set_request('method', method.upcase)
  set_request('headers', headers)
  set_request('parameters', parameters)
  set_request('payload', payload)

  set_response('status', r.code)
  set_response('body', r.body)
  set_response('headers', r.raw_headers)
end

#requestObject



6
7
8
# File 'lib/cucumber/http/world_extensions/request.rb', line 6

def request
  @request ||= {}
end

#set_request(key, value) ⇒ Object



10
11
12
# File 'lib/cucumber/http/world_extensions/request.rb', line 10

def set_request(key, value)
  request[key.to_sym] = value
end