mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-01 21:47:16 +00:00
45 lines
1.3 KiB
Ruby
45 lines
1.3 KiB
Ruby
# spec/system/support/cuprite_setup.rb
|
|
|
|
# First, load Cuprite Capybara integration
|
|
require "capybara/cuprite"
|
|
|
|
# Then, we need to register our driver to be able to use it later
|
|
# with #driven_by method.
|
|
Capybara.register_driver(:cuprite) do |app|
|
|
Capybara::Cuprite::Driver.new(
|
|
app,
|
|
**{
|
|
window_size: [1200, 800],
|
|
# See additional options for Dockerized environment in the respective section of this article
|
|
browser_options: {},
|
|
# Increase Chrome startup wait time (required for stable CI builds)
|
|
process_timeout: 10,
|
|
# Enable debugging capabilities
|
|
inspector: true,
|
|
# Allow running Chrome in a headful mode by setting HEADLESS env
|
|
headless: false
|
|
}
|
|
)
|
|
end
|
|
|
|
# Configure Capybara to use :cuprite driver by default
|
|
Capybara.default_driver = Capybara.javascript_driver = :cuprite
|
|
|
|
module CupriteHelpers
|
|
# Drop #pause anywhere in a test to stop the execution.
|
|
# Useful when you want to checkout the contents of a web page in the middle of a test
|
|
# running in a headful mode.
|
|
def pause
|
|
page.driver.pause
|
|
end
|
|
|
|
# Drop #debug anywhere in a test to open a Chrome inspector and pause the execution
|
|
def debug(*args)
|
|
page.driver.debug(*args)
|
|
end
|
|
end
|
|
|
|
RSpec.configure do |config|
|
|
config.include CupriteHelpers, type: :system
|
|
end
|