Module: EvilSystems::Settings
- Defined in:
- lib/evil_systems/settings.rb
Overview
Capybara settings (not covered by Rails system tests)
Class Method Summary collapse
-
.app_host ⇒ String
Finds the current app host via ENV, ‘hostname`, or defaults to “0.0.0.0”.
-
.cookie_domain ⇒ String
Finds the current cookie domain.
-
.initial_setup ⇒ Object
The setup to be run prior to the test suite.
- .prepend_session_to_capybara ⇒ Object
Class Method Details
.app_host ⇒ String
Finds the current app host via ENV, ‘hostname`, or defaults to “0.0.0.0”
8 9 10 |
# File 'lib/evil_systems/settings.rb', line 8 def self.app_host "http://#{ENV.fetch("APP_HOST", `hostname`&.strip&.downcase || "0.0.0.0")}" end |
.cookie_domain ⇒ String
Finds the current cookie domain
14 15 16 17 18 19 20 21 |
# File 'lib/evil_systems/settings.rb', line 14 def self. URI.parse(app_host).host.then do |host| # If host is a top-level domain next host unless host.include?(".") ".#{host}" end end |
.initial_setup ⇒ Object
The setup to be run prior to the test suite
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/evil_systems/settings.rb', line 24 def self.initial_setup ::Capybara.app_host = app_host # Make server listening on all hosts ::Capybara.server_host = "0.0.0.0" # Silence puma ::Capybara.server = :puma, {Silent: true} # Don't wait too long in `have_xyz` matchers ::Capybara.default_max_wait_time = 2 # Normalizes whitespaces when using `has_text?` and similar matchers ::Capybara.default_normalize_ws = true # Where to store artifacts (e.g. screenshots, downloaded files, etc.) ::Capybara.save_path = ENV.fetch("CAPYBARA_ARTIFACTS", "./tmp/capybara") # Disable animations in Capybara by default ::Capybara.disable_animation = ENV.fetch("DISABLE_ANIMATION", "true") == "true" end |
.prepend_session_to_capybara ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/evil_systems/settings.rb', line 48 def self. ::Capybara.singleton_class.prepend(Module.new do attr_accessor :last_used_session def using_session(name, &block) self.last_used_session = name super ensure self.last_used_session = nil end end) end |