Module: FHTTPClientFakeResponse

Defined in:
lib/f_http_client/rspec/support/helpers/fake_response.rb

Instance Method Summary collapse

Instance Method Details

#build_httparty_response(code: 200, parsed_response: {}) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/f_http_client/rspec/support/helpers/fake_response.rb', line 4

def build_httparty_response(code: 200, parsed_response: {})
  request_object = HTTParty::Request.new Net::HTTP::Get, '/'
  response_object = Net::HTTPResponse::CODE_TO_OBJ[code.to_s].new('1.1', code, '')
  allow(response_object).to receive(:body)

  HTTParty::Response.new(request_object, response_object, -> { parsed_response })
end