capybara.rb 761 B

12345678910111213141516171819202122232425262728293031
  1. # frozen_string_literal: true
  2. Capybara.server_host = 'localhost'
  3. Capybara.server_port = 3000
  4. Capybara.app_host = "http://#{Capybara.server_host}:#{Capybara.server_port}"
  5. require 'selenium/webdriver'
  6. Capybara.register_driver :chrome do |app|
  7. Capybara::Selenium::Driver.new(app, browser: :chrome)
  8. end
  9. Capybara.register_driver :headless_chrome do |app|
  10. options = Selenium::WebDriver::Chrome::Options.new
  11. options.add_argument '--headless=new'
  12. options.add_argument '--window-size=1680,1050'
  13. Capybara::Selenium::Driver.new(
  14. app,
  15. browser: :chrome,
  16. options: options
  17. )
  18. end
  19. Capybara.javascript_driver = :headless_chrome
  20. RSpec.configure do |config|
  21. config.before(:each, type: :system) do
  22. driven_by Capybara.javascript_driver
  23. end
  24. end