module EvilSystems::Helpers

Helpers to make life easier

Public Instance Methods

absolute_image_path() click to toggle source

Use our `Capybara.save_path` to store screenshots with other capybara artifacts (Rails screenshots path is not configurable github.com/rails/rails/blob/49baf092439fc74fc3377b12e3334c3dd9d0752f/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb#L79) @return [String]

# File lib/evil_systems/helpers.rb, line 13
def absolute_image_path
  return ::Rails.root.join("#{::Capybara.save_path}/screenshots/#{image_name}.png") if defined? ::Rails

  File.join("#{::Capybara.save_path}/screenshots/#{image_name}.png")
end
dom_id(*args) click to toggle source

Convert dom_id to a selector. @example

dom_id(Facility.first)
# => "#facility-1"

@return [String]

# File lib/evil_systems/helpers.rb, line 40
def dom_id(*args)
  "##{super}"
end
image_path() click to toggle source

Use relative path in screenshot message to make it clickable in VS Code when running in Docker @return [String]

# File lib/evil_systems/helpers.rb, line 21
def image_path
  return absolute_image_path.relative_path_from(::Rails.root).to_s if defined? ::Rails

  absolute_image_path.relative_path_from(Dir.pwd)
end
take_screenshot() click to toggle source

Make failure screenshots compatible with multi-session setup @return void

Calls superclass method
# File lib/evil_systems/helpers.rb, line 29
def take_screenshot
  return super unless ::Capybara.last_used_session

  ::Capybara.using_session(::Capybara.last_used_session) { super }
end