Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,6 @@ nbproject
*.iws
.idea/
.vagrant/

# Ignore chromedriver binary (for test environment)
/bin/chromedriver
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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$$

Expand Down
32 changes: 31 additions & 1 deletion spec/rails_helper.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down