Skip to content

Commit 4945a8d

Browse files
committed
test: config Rails and Capybara to run inside a container #118
1 parent dbf80da commit 4945a8d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

spec/rails_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is copied to spec/ when you run 'rails generate rspec:install'
22
require "spec_helper"
3-
ENV["RAILS_ENV"] ||= "test"
3+
ENV["RAILS_ENV"] = "test"
44
require_relative "../config/environment"
55
# Prevent database truncation if the environment is production
66
abort("The Rails environment is running in production mode!") if Rails.env.production?

spec/support/capybara.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@
77
end
88

99
Capybara.register_driver :selenium_chrome_headless do |app|
10-
options = Selenium::WebDriver::Chrome::Options.new(args: %w[headless disable-gpu window-size=1400,1400])
10+
chrome_flags = %w[headless disable-gpu window-size=1400,1400]
1111

12+
if ENV["DOCKER_CONTAINER"]
13+
chrome_flags.concat(%w[no-sandbox disable-dev-shm-usage])
14+
end
15+
16+
options = Selenium::WebDriver::Chrome::Options.new(args: chrome_flags)
1217
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
1318
end
1419

0 commit comments

Comments
 (0)