Sha256: 610f751eafcca201267960e634bd9e6b544d6940ff4a679337543f60e5f27bf9

Contents?: true

Size: 1.22 KB

Versions: 11

Compression:

Stored size: 1.22 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.
      module Switchable
        DEFAULT    = :chrome_headless
        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

11 entries across 11 versions & 1 rubygems

Version Path
ndr_dev_support-7.3.1 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-7.3.0 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-7.2.6 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-7.2.5 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-7.2.4 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-7.2.3 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-7.2.2 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-7.2.1 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-7.2.0 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-7.1.0 lib/ndr_dev_support/integration_testing/drivers/switchable.rb
ndr_dev_support-7.0.0 lib/ndr_dev_support/integration_testing/drivers/switchable.rb