diff options
-rw-r--r-- | features/support/capybara.rb | 4 | ||||
-rw-r--r-- | spec/support/capybara.rb | 10 | ||||
-rw-r--r-- | spec/support/test_env.rb | 11 |
3 files changed, 12 insertions, 13 deletions
diff --git a/features/support/capybara.rb b/features/support/capybara.rb index c0c489d2775..33ca76bea8d 100644 --- a/features/support/capybara.rb +++ b/features/support/capybara.rb @@ -3,7 +3,7 @@ require 'capybara/poltergeist' require 'capybara-screenshot/spinach' # Give CI some extra time -timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 30 : 10 +timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 60 : 30 Capybara.javascript_driver = :poltergeist Capybara.register_driver :poltergeist do |app| @@ -25,5 +25,5 @@ Capybara.ignore_hidden_elements = false 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 aa14709bc9c..b8ca8f22a3d 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']) ? 30 : 10 +timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 60 : 30 Capybara.javascript_driver = :poltergeist Capybara.register_driver :poltergeist do |app| @@ -26,7 +27,10 @@ Capybara.ignore_hidden_elements = true Capybara::Screenshot.prune_strategy = :keep_last_run RSpec.configure do |config| - config.before(:suite) do - TestEnv.warm_asset_cache + 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 78be23bd853..9db489e9a9b 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -169,16 +169,11 @@ module TestEnv # # Otherwise they'd be created by the first test, often timing out and # causing a transient test failure - def warm_asset_cache - return if warm_asset_cache? + def eager_load_driver_server return unless defined?(Capybara) - Capybara.current_session.driver.visit '/' - end - - def warm_asset_cache? - cache = Rails.root.join(*%w(tmp cache assets test)) - Dir.exist?(cache) && Dir.entries(cache).length > 2 + puts "Starting the Capybara driver' server..." + Capybara.current_session.visit '/' end private |