From 89179893eb05b92bac32dca54fdf2769696d909b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Thu, 30 Mar 2017 16:30:05 +0200 Subject: [PATCH 1/2] Eager-load the Capybara server to prevent timeouts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- features/support/capybara.rb | 2 +- spec/support/capybara.rb | 2 +- spec/support/test_env.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/features/support/capybara.rb b/features/support/capybara.rb index 456ec4deaf5ce1..96e1421462f6e7 100644 --- a/features/support/capybara.rb +++ b/features/support/capybara.rb @@ -25,5 +25,5 @@ Capybara::Screenshot.prune_strategy = :keep_last_run Spinach.hooks.before_run do - TestEnv.warm_asset_cache unless ENV['CI'] || ENV['CI_SERVER'] + TestEnv.eager_load_driver_server end diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index cebc972be7ed8e..d4e38eb2a51a7b 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -27,6 +27,6 @@ RSpec.configure do |config| config.before(:suite) do - TestEnv.warm_asset_cache unless ENV['CI'] || ENV['CI_SERVER'] + TestEnv.eager_load_driver_server end end diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb index eed846405af2c1..96307f0172c12e 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -171,7 +171,7 @@ def copy_forked_repo_with_submodules(project) # # Otherwise they'd be created by the first test, often timing out and # causing a transient test failure - def warm_asset_cache + def eager_load_driver_server return unless defined?(Capybara) Capybara.current_session.driver.visit '/' -- GitLab From 324a2b2913cc6e4258dfb780cb6222c16eb60e21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Fri, 31 Mar 2017 09:55:46 +0200 Subject: [PATCH 2/2] Properly eagerly-load the Capybara server for JS feature specs only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- features/support/capybara.rb | 2 +- spec/support/capybara.rb | 8 ++++++-- spec/support/test_env.rb | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/features/support/capybara.rb b/features/support/capybara.rb index 96e1421462f6e7..33ca76bea8d1b8 100644 --- a/features/support/capybara.rb +++ b/features/support/capybara.rb @@ -3,7 +3,7 @@ require 'capybara-screenshot/spinach' # Give CI some extra time -timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 40 : 10 +timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 60 : 30 Capybara.javascript_driver = :poltergeist Capybara.register_driver :poltergeist do |app| diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index d4e38eb2a51a7b..b8ca8f22a3d2cb 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -1,10 +1,11 @@ +# rubocop:disable Style/GlobalVars require 'capybara/rails' require 'capybara/rspec' require 'capybara/poltergeist' require 'capybara-screenshot/rspec' # Give CI some extra time -timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 40 : 10 +timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 60 : 30 Capybara.javascript_driver = :poltergeist Capybara.register_driver :poltergeist do |app| @@ -26,7 +27,10 @@ Capybara::Screenshot.prune_strategy = :keep_last_run RSpec.configure do |config| - config.before(:suite) do + config.before(:context, :js) do + next if $capybara_server_already_started + TestEnv.eager_load_driver_server + $capybara_server_already_started = true end end diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb index 96307f0172c12e..32b64c1987052d 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -174,7 +174,8 @@ def copy_forked_repo_with_submodules(project) def eager_load_driver_server return unless defined?(Capybara) - Capybara.current_session.driver.visit '/' + puts "Starting the Capybara driver' server..." + Capybara.current_session.visit '/' end private -- GitLab