Last active
October 23, 2019 08:30
-
-
Save pabuisson/583f8ef6839671dc1386bf38814f9202 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
# 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