Skip to content

Commit 56759df

Browse files
Merge pull request #3405 from DMPRoadmap/fix_rspec_tests_for_bootstrap_upgrade
Fix for failing Rubocop tests.
2 parents 0f805f6 + 708dee4 commit 56759df

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

config/environments/test.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
# config.action_view.annotate_rendered_view_with_filenames = true
6363

6464
config.i18n.enforce_available_locales = false
65+
66+
# Add config/routes_test.rb to routes
67+
config.paths['config/routes.rb'] << Rails.root.join('config/routes_test.rb')
6568
end
6669

6770
# Used by Rails' routes url_helpers (typically when including a link in an email)

config/routes_test.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
Rails.application.routes.draw do
4+
# Define your test-specific routes here
5+
6+
# This route will return an empty response with a 200 OK status code
7+
# when the browser requests the favicon.ico file.
8+
get '/favicon.ico', to: proc { |_env| [200, {}, ['']] }
9+
end

spec/support/capybara.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,23 @@
66
# Use the fast rack_test driver for non-feature tests by default
77
Capybara.default_driver = :rack_test
88

9+
# Create a custom driver based on Capybara's :selenium_chrome_headless driver
10+
# This resolves a ElementClickInterceptedError when executing `click_button 'Sign in'` with DMP Assistant
11+
Capybara.register_driver :selenium_chrome_headless_add_window_size do |app|
12+
# Get a copy of the default options for Capybara's :selenium_chrome_headless driver
13+
options = Capybara.drivers[:selenium_chrome_headless].call.options[:options].dup
14+
options.add_argument('--window-size=1920,1080') # default window-size is only (800x600)
15+
# Create a new Selenium driver with the customised options
16+
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
17+
end
18+
919
RSpec.configure do |config|
1020
config.before(:each, type: :feature, js: false) do
1121
Capybara.use_default_driver
1222
end
1323

1424
# Use the Selenium headless Chrome driver for feature tests
1525
config.before(:each, type: :feature, js: true) do
16-
Capybara.current_driver = :selenium_chrome_headless
26+
Capybara.current_driver = :selenium_chrome_headless_add_window_size
1727
end
1828
end

0 commit comments

Comments
 (0)