module EvilSystems::Settings
Capybara settings (not covered by Rails system tests)
Public Class Methods
app_host()
click to toggle source
Finds the current app host via ENV, `hostname`, or defaults to “0.0.0.0” @return [String]
# 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
initial_setup()
click to toggle source
The setup to be run prior to the test suite
# File lib/evil_systems/settings.rb, line 24 def self.initial_setup prepend_session_to_capybara ::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") end
Private Class Methods
prepend_session_to_capybara()
click to toggle source
# File lib/evil_systems/settings.rb, line 45 def self.prepend_session_to_capybara ::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
Public Instance Methods
using_session(name, &block)
click to toggle source
Calls superclass method
# File lib/evil_systems/settings.rb, line 49 def using_session(name, &block) self.last_used_session = name super ensure self.last_used_session = nil end