From 8728cb5ec450a746f60a40684a4a38b46763c2cf Mon Sep 17 00:00:00 2001 From: Web-Go-To Date: Tue, 18 Jun 2019 23:59:48 -0700 Subject: [PATCH] Silence Puma's startup messages in JS specs When Capybara starts the first JavaScript spec of a run, it starts Puma and prints out the Puma startup messages: Capybara starting Puma... * Version 3.12.1 , codename: Llamas in Pajamas * Min threads: 0, max threads: 4 * Listening on tcp://127.0.0.1:62516 By setting `Silent: true`, we can prevent those messages from being printed. A bit of background: https://github.com/rspec/rspec-rails/issues/1897 Proof that Capybara uses Puma as its default server: https://github.com/teamcapybara/capybara/blob/3.24.0/lib/capybara.rb#L247-L249 --- lib/suspenders/generators/js_driver_generator.rb | 6 +++++- templates/capybara_silence_puma.rb | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 templates/capybara_silence_puma.rb diff --git a/lib/suspenders/generators/js_driver_generator.rb b/lib/suspenders/generators/js_driver_generator.rb index a2a89ac..b686c0d 100644 --- a/lib/suspenders/generators/js_driver_generator.rb +++ b/lib/suspenders/generators/js_driver_generator.rb @@ -8,8 +8,12 @@ def add_gems Bundler.with_clean_env { run "bundle install" } end - def configure_chromedriver + def configure_capybara copy_file "chromedriver.rb", "spec/support/chromedriver.rb" + copy_file( + "capybara_silence_puma.rb", + "spec/support/capybara_silence_puma.rb", + ) end end end diff --git a/templates/capybara_silence_puma.rb b/templates/capybara_silence_puma.rb new file mode 100644 index 0000000..e58eba3 --- /dev/null +++ b/templates/capybara_silence_puma.rb @@ -0,0 +1 @@ +Capybara.server = :puma, { Silent: true }