Skip to content

Instantly share code, notes, and snippets.

@pabuisson
Last active October 23, 2019 08:30
Show Gist options
  • Save pabuisson/583f8ef6839671dc1386bf38814f9202 to your computer and use it in GitHub Desktop.
Save pabuisson/583f8ef6839671dc1386bf38814f9202 to your computer and use it in GitHub Desktop.
# https://github.com/teamcapybara/capybara/issues/1121
class SslServer
def responsive?
return false if @server_thread && @server_thread.join(0)
http = Net::HTTP.new(host, @port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
res = http.get('/__identify__')
if res.is_a?(Net::HTTPSuccess) or res.is_a?(Net::HTTPRedirection)
return res.body == @app.object_id.to_s
end
rescue SystemCallError
return false
end
end
# Extend Capybara Server with our module
Capybara::Server.prepend(SslServer)
# Select the Capybara server
Capybara.server = :thin_ssl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment