Skip to content

Commit

Permalink
Switch to using suspender's Capybara configuration
Browse files Browse the repository at this point in the history
With more recent Chromedriver versions, we need to specify the headless
window size which this does. Plus more familiarity with this
configuration.
  • Loading branch information
nickcharlton committed Oct 6, 2020
1 parent 140e721 commit dd54052
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
20 changes: 0 additions & 20 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

require "rspec/rails"
require "shoulda/matchers"
require "selenium/webdriver"

Dir[Rails.root.join("../../spec/support/**/*.rb")].each { |file| require file }

Expand All @@ -31,22 +30,3 @@ module Features
end

ActiveRecord::Migration.maintain_test_schema!

Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, browser: :chrome)
end

Capybara.register_driver :headless_chrome do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
chromeOptions: {
args: %w[headless enable-features=NetworkService,NetworkServiceInProcess]
}
)
Capybara::Selenium::Driver.new app,
browser: :chrome,
desired_capabilities: capabilities
end

Capybara.javascript_driver = :selenium_chrome_headless

Capybara.server = :webrick
30 changes: 30 additions & 0 deletions spec/support/webdrivers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require "selenium/webdriver"

Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, browser: :chrome)
end

Capybara.register_driver :headless_chrome do |app|
options = ::Selenium::WebDriver::Chrome::Options.new
options.headless!
options.add_argument "--window-size=1680,1050"

Capybara::Selenium::Driver.new(
app,
browser: :chrome,
options: options,
)
end

Capybara.javascript_driver = :headless_chrome
Capybara.server = :webrick

RSpec.configure do |config|
config.before(:each, type: :system) do
driven_by :rack_test
end

config.before(:each, type: :system, js: true) do
driven_by Capybara.javascript_driver
end
end

0 comments on commit dd54052

Please sign in to comment.