Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

Commit

Permalink
Fix system tests
Browse files Browse the repository at this point in the history
Rails 6.0 assumes the use of the `selenium-webdriver` gem, and so tries
to:

1. Require 'selenium/webdriver' - fix by adding an empty file with that
   path and adding it to $LOAD_PATH
2. Load `Selenium::WebDriver::*` constants due to the default `:chrome`
   for the `using:` argument - fix by adding a non-existent `:cuprite`
   browser so that we fall out of Rails' case statement (Cuprite ignores
   this value since it only works with Chrome anyway)
  • Loading branch information
rjpaskin committed May 15, 2023
1 parent 065b8b7 commit 0349fdf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ def has_action_cable_testing?

require 'rspec/rails'

file = Pathname('../tmp/workaround/selenium/webdriver.rb').expand_path(__dir__)
file.dirname.mkpath unless file.dirname.directory?
file.write('') unless file.exist?
$LOAD_PATH << file.dirname.dirname.to_s

Dir[Rails.root.join('spec/support/*.rb')].each { |file| require file }
Dir[Rails.root.join('spec/support/shared_contexts/*.rb')].each { |file| require file }
Dir[Rails.root.join('spec/support/shared_examples/*.rb')].each { |file| require file }
Expand Down
3 changes: 2 additions & 1 deletion spec/support/capybara.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
end

config.before(:each, type: :system, js: true) do
driven_by :cuprite
# `using: :chrome` (the default) errors because Rails tries to use selenium-webdriver
driven_by :cuprite, using: :cuprite

@fp_debug_thread = Thread.new do
Thread.current.abort_on_exception = true
Expand Down

0 comments on commit 0349fdf

Please sign in to comment.