Skip to content

Instantly share code, notes, and snippets.

@andremrsantos
Created June 5, 2016 00:57
Show Gist options
  • Save andremrsantos/f447a1bb73f3d1ccbad9e400b60bdc41 to your computer and use it in GitHub Desktop.
Save andremrsantos/f447a1bb73f3d1ccbad9e400b60bdc41 to your computer and use it in GitHub Desktop.
require "webmock"
require "http/client"
require "xml"
# Mocking the web request
WebMock.stub(:get, "mymock.com/index").to_return(body: "")
client = HTTP::Client.new("mymock.com").tap do |c|
c.connect_timeout = 30.seconds
c.dns_timeout = 10.seconds
c.read_timeout = 5.minutes
end
response = client.get("/index")
puts "Status Code:"
puts response.status_code
puts "Body:"
puts response.body
parsed = XML.parse_html(response.body)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment