1
0

capybara.rb 1009 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. def common_chrome_options
  7. options = Selenium::WebDriver::Chrome::Options.new
  8. options.add_argument '--window-size=1680,1050'
  9. options.add_argument '--disable-search-engine-choice-screen'
  10. options
  11. end
  12. Capybara.register_driver :chrome do |app|
  13. Capybara::Selenium::Driver.new(app, browser: :chrome, options: common_chrome_options)
  14. end
  15. Capybara.register_driver :headless_chrome do |app|
  16. options = common_chrome_options
  17. options.add_argument '--headless=new'
  18. Capybara::Selenium::Driver.new(
  19. app,
  20. browser: :chrome,
  21. options: options
  22. )
  23. end
  24. Capybara.javascript_driver = :headless_chrome
  25. RSpec.configure do |config|
  26. config.before(:each, type: :system) do
  27. driven_by :rack_test
  28. end
  29. config.before(:each, :js, type: :system) do
  30. driven_by Capybara.javascript_driver
  31. end
  32. end