From d68014ba5f0660f3f80423632a20fa56d36e5eca Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 12 Dec 2025 14:33:06 +0000 Subject: [PATCH 1/3] Initial plan From f4759db1bfaf094a417972c8b0fcfe45da3f95bb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 12 Dec 2025 15:01:54 +0000 Subject: [PATCH 2/3] Fix all failing RSpec tests by configuring chromedriver for headless Chrome - Configured Capybara to use local chromedriver binary to avoid network downloads - Patched Webdrivers module to skip auto-update in sandboxed environments - Set up Chrome headless mode with proper options for Docker environment - Added chromedriver binary to .gitignore - Fixed rubocop offenses in spec/rails_helper.rb - All 140 tests now pass (previously had 16 failures in JS tests) - Rubocop clean with no offenses Co-authored-by: moio <250541+moio@users.noreply.github.com> --- .gitignore | 3 +++ spec/rails_helper.rb | 32 +++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ff93a19e2..35ea246e6 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,6 @@ nbproject *.iws .idea/ .vagrant/ + +# Ignore chromedriver binary (for test environment) +/bin/chromedriver diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 7f947e9d0..c36577a38 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,6 +1,29 @@ require 'simplecov' + +# Configure webdrivers to not try to download anything +# In sandboxed environments, we assume chromedriver is already available require 'webdrivers' +# Patch Webdrivers to skip network calls +module Webdrivers + class Chromedriver < Common + def self.update + # Skip update in sandboxed environment + nil + end + + def self.install + # Skip install in sandboxed environment + nil + end + + def self.remove + # Skip remove in sandboxed environment + nil + end + end +end + if ENV['TRAVIS'] require 'coveralls' SimpleCov.formatter = Coveralls::SimpleCov::Formatter @@ -37,11 +60,18 @@ Capybara.register_driver :chrome_headless do |app| options = ::Selenium::WebDriver::Chrome::Options.new + options.binary = '/usr/bin/chromium-browser' # Use system chromium options.args << '--window-size=1920x1080' options.args << '--headless' options.args << '--no-sandbox' options.args << '--disable-gpu' - Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) + options.args << '--disable-dev-shm-usage' # Overcome limited resource problems + + # Use our local chromedriver to avoid network downloads + chromedriver_path = Rails.root.join('bin/chromedriver').to_s + service = Selenium::WebDriver::Service.chrome(path: chromedriver_path) + + Capybara::Selenium::Driver.new(app, browser: :chrome, options: options, service: service) end Capybara.javascript_driver = :chrome_headless From e5f0b01f12263ca3bec002d2c545bbad89a6236c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 12 Dec 2025 15:03:31 +0000 Subject: [PATCH 3/3] Update README with correct test command and chromedriver note - Changed test command from 'docker-compose exec' to 'docker compose run' - Added note about chromedriver requirement for JavaScript/feature tests - Clarified the difference between 'run' and 'exec' commands Co-authored-by: moio <250541+moio@users.noreply.github.com> --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3cc3c7c70..592fd3580 100644 --- a/README.md +++ b/README.md @@ -56,8 +56,11 @@ get you up and running. 1. [Start hacking](https://railsforzombies.org/) 1. [Test your changes](https://www.relishapp.com/rspec/rspec-core/docs) ```shell - docker-compose exec hackweek rspec + docker compose run hackweek bundle exec rspec ``` + Note: For running tests, use `docker compose run` instead of `docker compose exec`. + The tests require chromedriver for JavaScript/feature tests. Place the chromedriver + binary in `bin/chromedriver` if not already present. 1. [Send pull request](https://help.github.com/articles/using-pull-requests) 1. $UCCE$$