如何在SSL模式下使用Puma服务器运行Rails / Capybara?

时间:2018-04-30 21:29:59

标签: ruby-on-rails ssl capybara puma

我想让capybara在ssl上运行测试puma服务器。需要帮助配置它,请:

Capybara.register_server :ssl_puma do |app, port, host|
  require 'rack/handler/puma'
  Rack::Handler::Puma.run(app, Host: host, Port: port, Threads: "0:1") do |server| 
    ctx = Puma::MiniSSL::Context.new
    ctx.key = ENV['SSL_KEY_PATH']
    ctx.cert = ENV['SSL_CERT_PATH']
    ctx.verify_mode = Puma::MiniSSL::VERIFY_NONE

    server.add_ssl_listener host, port, ctx # this line is wrong, but that's the gyst of what needs to happen
  end
end

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

如果您使用最新版本的Capybara,我相信您应该可以做类似的事情

Capybara.server = :puma, { Host: "ssl://#{Capybara.server_host}?key=#{ENV['SSL_KEY_PATH']}&cert=#{ENV['SSL_CERT_PATH']" }