-
-
Save supairish/b074ec9b5f1d676b7fc391ed5e873306 to your computer and use it in GitHub Desktop.
Test of webrick configured with self signed cert
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
html = DATA.read | |
require "capybara/dsl" | |
require "capybara/poltergeist" | |
require "openssl" | |
app = proc { |env| [200, { "Content-Type" => "text/html" }, [html] ] } | |
Capybara.register_driver :poltergeist do |app| | |
Capybara::Poltergeist::Driver.new(app, debug: true, js_errors: true, timeout: 60, logger: $stdout, | |
phantomjs_options: %w[--load-images=yes --ignore-ssl-errors=yes]) | |
end | |
Capybara.register_server :webrick_ssl do |app, port, host| | |
require "webrick/https" | |
require "rack/handler/webrick" | |
# This runs webrick with auto-generated self-signed certificate | |
Rack::Handler::WEBrick.run(app, | |
Host: host, | |
Port: port, | |
SSLEnable: true, | |
SSLCertName: [["CN", "www.somehost.cz"]], | |
AccessLog: [[$stdout, WEBrick::AccessLog::COMMON_LOG_FORMAT]], | |
Logger: WEBrick::Log.new($stdout)) | |
end | |
Capybara.configure do |config| | |
config.javascript_driver = :poltergeist | |
config.default_driver = :poltergeist | |
config.default_max_wait_time = 15 | |
config.exact = true # match only exact texts, not substrings | |
config.server = :webrick_ssl | |
config.server_host = "www.somehost.cz" | |
config.server_port = 3030 | |
config.always_include_port = true | |
config.app_host = "https://www.somehost.cz:3030" | |
end | |
Capybara.app = app | |
# sess = Capybara::Session.new(:poltergeist, app) | |
sess = Capybara.current_session | |
sess.visit('/') | |
puts sess.find('body').text | |
__END__ | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Document</title> | |
</head> | |
<body> | |
simple | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment