Class: RightDevelop::Testing::Client::Rest::Request::Playback::FakeNetHttpResponse

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

Overview

fake Net::HTTPResponse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response_hash, response_metadata) ⇒ FakeNetHttpResponse

Returns a new instance of FakeNetHttpResponse.



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/right_develop/testing/clients/rest/requests/playback.rb', line 45

def initialize(response_hash, )
  @delay_seconds = .delay_seconds
  @elapsed_seconds = Integer(response_hash[:elapsed_seconds] || 0)
  @code = .http_status.to_s
  @headers = .headers.inject({}) do |h, (k, v)|
    h[k] = Array(v)  # expected to be an array
    h
  end
  @body = .body  # optional
  @call_count = Integer(response_hash[:call_count]) || 1
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



43
44
45
# File 'lib/right_develop/testing/clients/rest/requests/playback.rb', line 43

def body
  @body
end

#call_countObject (readonly)

Returns the value of attribute call_count.



43
44
45
# File 'lib/right_develop/testing/clients/rest/requests/playback.rb', line 43

def call_count
  @call_count
end

#codeObject (readonly)

Returns the value of attribute code.



43
44
45
# File 'lib/right_develop/testing/clients/rest/requests/playback.rb', line 43

def code
  @code
end

#delay_secondsObject (readonly)

Returns the value of attribute delay_seconds.



43
44
45
# File 'lib/right_develop/testing/clients/rest/requests/playback.rb', line 43

def delay_seconds
  @delay_seconds
end

#elapsed_secondsObject (readonly)

Returns the value of attribute elapsed_seconds.



43
44
45
# File 'lib/right_develop/testing/clients/rest/requests/playback.rb', line 43

def elapsed_seconds
  @elapsed_seconds
end

Instance Method Details

#[](key) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/right_develop/testing/clients/rest/requests/playback.rb', line 57

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

#to_hashObject



65
# File 'lib/right_develop/testing/clients/rest/requests/playback.rb', line 65

def to_hash; @headers; end