summaryrefslogtreecommitdiff
path: root/features/support/capybara.rb
blob: 47372df152d59a77e6c900100ff7afbe26cdff9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require 'spinach/capybara'
require 'capybara/poltergeist'

# Give CI some extra time
timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 90 : 15

Capybara.javascript_driver = :poltergeist
Capybara.register_driver :poltergeist do |app|
  Capybara::Poltergeist::Driver.new(
    app,
    js_errors: true,
    timeout: timeout,
    window_size: [1366, 768],
    phantomjs_options: [
      '--load-images=no'
    ]
  )
end

Capybara.default_max_wait_time = timeout
Capybara.ignore_hidden_elements = false

unless ENV['CI'] || ENV['CI_SERVER']
  require 'capybara-screenshot/spinach'

  # Keep only the screenshots generated from the last failing test suite
  Capybara::Screenshot.prune_strategy = :keep_last_run
end

Spinach.hooks.before_run do
  TestEnv.warm_asset_cache unless ENV['CI'] || ENV['CI_SERVER']
end