Class: RightDevelop::Testing::Client::Rest::Request::Record::TimeoutNetHttpResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/right_develop/testing/clients/rest/requests/record.rb

Overview

simulated 504 Net::HTTPResponse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTimeoutNetHttpResponse

Returns a new instance of TimeoutNetHttpResponse.



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/right_develop/testing/clients/rest/requests/record.rb', line 41

def initialize
  message = 'Timeout'
  @code = 504
  @headers = {
    'content-type'   => 'text/plain',
    'content-length' => ::Rack::Utils.bytesize(message).to_s,
    'connection'     => 'close',
  }.inject({}) do |h, (k, v)|
    h[k] = Array(v)  # expected to be an array
    h
  end
  @body = message
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



39
40
41
# File 'lib/right_develop/testing/clients/rest/requests/record.rb', line 39

def body
  @body
end

#codeObject (readonly)

Returns the value of attribute code.



39
40
41
# File 'lib/right_develop/testing/clients/rest/requests/record.rb', line 39

def code
  @code
end

Instance Method Details

#[](key) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/right_develop/testing/clients/rest/requests/record.rb', line 55

def [](key)
  if header = @headers[key.downcase]
    header.join(', ')
  else
    nil
  end
end

#to_hashObject



63
# File 'lib/right_develop/testing/clients/rest/requests/record.rb', line 63

def to_hash; @headers; end