capybara.rb 801 Bytes
Newer Older
1
require 'capybara/poltergeist'
2
require 'capybara-screenshot/spinach'
3

4
# Give CI some extra time
5
timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 60 : 30
6

7 8
Capybara.javascript_driver = :poltergeist
Capybara.register_driver :poltergeist do |app|
9 10 11 12 13
  Capybara::Poltergeist::Driver.new(
    app,
    js_errors: true,
    timeout: timeout,
    window_size: [1366, 768],
14 15
    url_whitelist: %w[localhost 127.0.0.1],
    url_blacklist: %w[.mp4 .png .gif .avi .bmp .jpg .jpeg],
16
    phantomjs_options: [
17
      '--load-images=yes'
18 19
    ]
  )
20 21
end

22
Capybara.default_max_wait_time = timeout
23 24
Capybara.ignore_hidden_elements = false

25 26
# Keep only the screenshots generated from the last failing test suite
Capybara::Screenshot.prune_strategy = :keep_last_run
27 28

Spinach.hooks.before_run do
29
  TestEnv.eager_load_driver_server
30
end