Search code examples
capybararspec-railspuma

How to keep puma server running between rspec tests


I am using rspec and capybara for testing of features specs that contain javascript. Each time I run a test, a separate instance of the puma server is started e.g.

Capybara starting Puma...
* Version 3.11.0 , codename: Love Song
* Min threads: 0, max threads: 4
* Listening on tcp://127.0.0.1:64558

If I run the full test suite, this instance of puma is only started once, but if I am debugging a particular test, it is run every single time, which can greatly increasing the overall time taken to do the debuggging. Is there any way I can start and instance of the test puma web server and keep it running between individual test runs?


Solution

  • TL;DR; Not really

    The only way to do that would be to run the app yourself, tell Capybara where it's running (Capybara.app_host) and then tell Capybara not to run its own server, Capybara.run_server = false, just like if you were running Capybara against an external app. The problem with that is that Capybara would lose the ability to track request completion (which requires the server to run in process in its own thread), so syncing database reset, etc becomes a big issue. It's not really worth it.