driven_by.rb 1.0 KB

123456789101112131415161718192021222324252627282930
  1. require_relative './set_up'
  2. RSpec.configure do |config|
  3. config.before(:each, type: :system) do
  4. Capybara.register_server :puma_wrapper do |app, port, host, **_options|
  5. # update fqdn Setting according to random assigned Rack server port
  6. Setting.set('fqdn', "#{host}:#{port}")
  7. # start a silenced Puma as application server
  8. Capybara.servers[:puma].call(app, port, host, { Silent: true, Host: '0.0.0.0', Threads: '0:16' })
  9. end
  10. Capybara.server = :puma_wrapper
  11. # set the Host from gather container IP for CI runs
  12. if ENV['CI'].present?
  13. ip_address = Socket.ip_address_list.detect(&:ipv4_private?).ip_address
  14. host!("http://#{ip_address}")
  15. end
  16. # set custom Zammad driver (e.g. zammad_chrome) for special
  17. # functionalities and CI requirements
  18. driven_by(:"zammad_#{ENV.fetch('BROWSER', 'firefox')}")
  19. browser_width = ENV['BROWSER_WIDTH'] || 1024
  20. browser_height = ENV['BROWSER_HEIGHT'] || 800
  21. page.driver.browser.manage.window.resize_to(browser_width, browser_height)
  22. end
  23. end