Module: Beaker::DSL::Helpers::WebHelpers
- Included in:
- Beaker::DSL::Helpers
- Defined in:
- lib/beaker/dsl/helpers/web_helpers.rb
Overview
Convenience methods for checking links and moving web content to hosts
Instance Method Summary collapse
-
#link_exists?(link) ⇒ Boolean
Determine is a given URL is accessible.
-
#port_open_within?(host, port = 8140, seconds = 120) ⇒ Boolean
Blocks until the port is open on the host specified, returns false on failure.
Instance Method Details
#link_exists?(link) ⇒ Boolean
Determine is a given URL is accessible
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/beaker/dsl/helpers/web_helpers.rb', line 20 def link_exists?(link) begin require "net/http" require "net/https" require "open-uri" url = URI.parse(link) http = Net::HTTP.new(url.host, url.port) http.use_ssl = (url.scheme == 'https') http.verify_mode = (OpenSSL::SSL::VERIFY_NONE) http.start do |http| return http.head(url.request_uri).code == "200" end rescue return false end end |
#port_open_within?(host, port = 8140, seconds = 120) ⇒ Boolean
Blocks until the port is open on the host specified, returns false on failure
9 10 11 12 13 |
# File 'lib/beaker/dsl/helpers/web_helpers.rb', line 9 def port_open_within?( host, port = 8140, seconds = 120 ) repeat_for( seconds ) do host.port_open?( port ) end end |