Module: NdrDevSupport::IntegrationTesting::Screenshot::SessionExtensions
- Defined in:
- lib/ndr_dev_support/integration_testing/screenshot.rb
Overview
Adds variant of Capybara’s #within_window method, that doesn’t return to the preview window on an exception. This allows us to screenshot a popup automatically if a test errors/fails whilst it has focus.
Instance Method Summary collapse
Instance Method Details
#within_screenshot_compatible_window(window_or_proc) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ndr_dev_support/integration_testing/screenshot.rb', line 15 def within_screenshot_compatible_window(window_or_proc) original = current_window case window_or_proc when Capybara::Window switch_to_window(window_or_proc) unless original == window_or_proc when Proc switch_to_window { window_or_proc.call } else fail ArgumentError, 'Unsupported window type!' end scopes << nil yield @scopes.pop switch_to_window(original) end |