Created
June 5, 2016 00:57
-
-
Save andremrsantos/f447a1bb73f3d1ccbad9e400b60bdc41 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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