Module: EvilSystems::Helpers
- Includes:
- ActionView::RecordIdentifier, CupriteHelpers, SessionHelpers
- Defined in:
- lib/evil_systems/helpers.rb
Overview
Helpers to make life easier
Instance Method Summary collapse
-
#absolute_image_path ⇒ String
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).
-
#dom_id(*args) ⇒ String
Convert dom_id to a selector.
-
#image_path ⇒ String
Use relative path in screenshot message to make it clickable in VS Code when running in Docker.
-
#take_screenshot ⇒ Object
Make failure screenshots compatible with multi-session setup.
Methods included from SessionHelpers
Methods included from CupriteHelpers
#debug, #pause, #wait_for_network_idle!
Instance Method Details
#absolute_image_path ⇒ String
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)
13 14 15 16 17 18 |
# File 'lib/evil_systems/helpers.rb', line 13 def absolute_image_path save_path = ::Capybara.save_path.presence || Rails.root.join("tmp/screenshots/#{image_name}") return ::Rails.root.join("#{save_path}/screenshots/#{image_name}.png") if defined? ::Rails File.join("#{save_path}/screenshots/#{image_name}.png") end |
#dom_id(*args) ⇒ String
Convert dom_id to a selector.
41 42 43 |
# File 'lib/evil_systems/helpers.rb', line 41 def dom_id(*args) "##{super}" end |
#image_path ⇒ String
Use relative path in screenshot message to make it clickable in VS Code when running in Docker
22 23 24 25 26 |
# File 'lib/evil_systems/helpers.rb', line 22 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 ⇒ Object
Make failure screenshots compatible with multi-session setup
30 31 32 33 34 |
# File 'lib/evil_systems/helpers.rb', line 30 def take_screenshot return super unless ::Capybara.respond_to?(:last_used_session) && ::Capybara.last_used_session ::Capybara.using_session(::Capybara.last_used_session) { super } end |