Sha256: e1ba67d4244c9a62926155ee004a24cfb018ca645215db02bbc784dbbc9215c1

Contents?: true

Size: 1.54 KB

Versions: 20

Compression:

Stored size: 1.54 KB

Contents

require 'show_me_the_cookies'

module NdrDevSupport
  module IntegrationTesting
    module Drivers
      # A meta-driver that allows the driver to be set using the `INTEGRATION_DRIVER`
      # environment variable (e.g. for a CI matrix), assuming that driver has been pre-registered
      # with Capybara.

      # Although the aim is to move to Chrome headless, we keep poltergeist as the default
      # driver for now. For motivation behind not changing immediately, see the "Differences
      # between Poltergeist and Selenium" section of:
      #
      #   https://about.gitlab.com/2017/12/19/moving-to-headless-chrome/
      #
      module Switchable
        DEFAULT    = :poltergeist
        CONFIGURED = ENV.fetch('INTEGRATION_DRIVER', DEFAULT).to_sym

        Capybara.register_driver(:switchable) do |app|
          configured_driver = Capybara.drivers[CONFIGURED]
          raise "Driver #{CONFIGURED} not found!" unless configured_driver

          configured_driver.call(app)
        end

        Capybara::Screenshot.register_driver(:switchable) do |driver, path|
          configured_screenshot_driver = Capybara::Screenshot.registered_drivers[CONFIGURED]
          raise "Screenshot driver #{CONFIGURED} not found!" unless configured_screenshot_driver

          configured_screenshot_driver.call(driver, path)
        end

        cookie_driver = ShowMeTheCookies.adapters[CONFIGURED]
        raise "Cookie driver #{CONFIGURED} not found!" unless cookie_driver

        ShowMeTheCookies.register_adapter(:switchable, cookie_driver)
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
ndr_dev_support-6.1.9 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-6.1.8 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-6.1.7 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-6.1.6 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-6.1.5 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-6.1.4 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-6.1.3 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-6.1.2 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-6.1.1 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-6.1.0 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-6.0.4 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-6.0.3 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-6.0.2 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-6.0.1 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-6.0.0 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-5.10.2 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-5.10.1 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-5.10.0 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-5.9.0 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-5.8.2 lib/ndr_dev_support/integration_testing/drivers/switchable.rb