sumitasok
5/17/2018 - 12:50 PM

Ruby fake a web response

Snippet to fake a web response for testing the response.

req = RestClient::Request.new(url: "www.google.com", method: 'get')
net_http_resp = Net::HTTPResponse.new(1.0, 200, "OK")
net_http_resp.add_field 'Set-Cookie', 'Monster'
resp = RestClient::Response.create(response_body.to_json, net_http_resp, req)