Sha256: 0840db8788bf5a1eb616457419a8c0b118f449654d9fe6aa4f59395dc1c28e2a

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require 'webdrivers/chromedriver'

# Allow to override the initial windows size
CAPYBARA_WINDOW_SIZE = ENV.fetch('CAPYBARA_WINDOW_SIZE', '1920x1080').split('x', 2).map(&:to_i)
CAPYBARA_WINDOW_WIDTH = CAPYBARA_WINDOW_SIZE[0]
CAPYBARA_WINDOW_HEIGHT = CAPYBARA_WINDOW_SIZE[1]

Capybara.javascript_driver = ENV.fetch('CAPYBARA_JAVASCRIPT_DRIVER', "solidus_chrome_headless").to_sym
Capybara.default_max_wait_time = 10
Capybara.server = :puma, { Silent: true } # A fix for rspec/rspec-rails#1897

Capybara.drivers[:selenium_chrome_headless].tap do |original_driver|
  Capybara.register_driver :solidus_chrome_headless do |app|
    original_driver.call(app).tap do |driver|
      driver.resize_window_to(
        driver.current_window_handle, CAPYBARA_WINDOW_WIDTH, CAPYBARA_WINDOW_HEIGHT
      )
    end
  end
end

require 'capybara-screenshot/rspec'

Capybara::Screenshot.register_driver(:solidus_chrome_headless) do |driver, path|
  driver.browser.save_screenshot(path)
end

require 'spree/testing_support/capybara_ext'

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
solidus_dev_support-2.7.0 lib/solidus_dev_support/rspec/capybara.rb
solidus_dev_support-2.6.0 lib/solidus_dev_support/rspec/capybara.rb
solidus_dev_support-2.5.6 lib/solidus_dev_support/rspec/capybara.rb
solidus_dev_support-2.5.5 lib/solidus_dev_support/rspec/capybara.rb