Skip to content

Commit 4f57810

Browse files
committed
Enable webdriver testing framework for Capybara
Required for UI user flow testing, currently missing due to previous tests either being request based or backend only.
1 parent 8a9566e commit 4f57810

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

spec/rails_helper.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,23 @@
1616
# Add additional requires below this line. Rails is not loaded until this point!
1717
require_relative "./support/factory_bot"
1818

19+
require "capybara/rails"
20+
21+
GovukTest.configure
22+
23+
Capybara.register_driver :headless_chrome do |app|
24+
chrome_options = GovukTest.headless_chrome_selenium_options
25+
chrome_options.add_argument("--disable-web-security")
26+
chrome_options.add_argument("--window-size=1400,1400")
27+
chrome_options.add_argument("--no-sandbox")
28+
29+
Capybara::Selenium::Driver.new(
30+
app,
31+
browser: :chrome,
32+
options: chrome_options,
33+
)
34+
end
35+
1936
# Requires supporting ruby files with custom matchers and macros, etc, in
2037
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
2138
# run as spec files by default. This means that files in spec/support that end
@@ -41,6 +58,10 @@
4158
abort e.to_s.strip
4259
end
4360
RSpec.configure do |config|
61+
config.before(:each, type: :system) do
62+
driven_by :headless_chrome
63+
end
64+
4465
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
4566
config.fixture_paths = [
4667
Rails.root.join("spec/fixtures"),

0 commit comments

Comments
 (0)