我刚刚安装了Puma,并且作为开发服务器运行正常。
但是当我运行集成测试时,Puma会在开发模式下启动,而不是测试模式。
Gemfile
group :test do
gem puma
end
test/test_helper.rb
class ActionDispatch::IntegrationTest
require 'rack/handler/puma'
Capybara.server = :puma
Capybara.register_server("puma") do |app, port|
server = Puma::Server.new(app)
server.add_tcp_listener(Capybara.server_host, port)
server.run
end
end
一个测试:
✗ RAILS_ENV="test" ruby -I test test/integration/computers_test.rb -n /polt/
Started with run options -n /polt/ --seed 3050
Puma starting in single mode...
* Version 3.8.2 (ruby 2.3.1-p112), codename: Sassy Salamander
* Min threads: 0, max threads: 4
* Environment: development
* Listening on tcp://127.0.0.1:49875
Use Ctrl-C to stop
...