Class: Rectory::Request

Inherits:
Object
  • Object
show all
Includes:
Celluloid
Defined in:
lib/rectory/request.rb

Overview

Test the expectated results of an HTTP request

Instance Method Summary collapse

Instance Method Details

#perform(expectation) ⇒ Rectory::Expectation

Test the expectated results of an HTTP request

Parameters:

Returns:



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rectory/request.rb', line 15

def perform(expectation)
  uri = URI expectation.url
  req = Net::HTTP::Get.new uri.request_uri

  res = Net::HTTP.start(uri.hostname, uri.port) do |http|
    http.request req
  end

  expectation.result[:location] = res['location']
  expectation.result[:code]     = res.code.to_i

  return expectation
end