Module: NdrDevSupport::IntegrationTesting::DSL::SessionExtensions

Defined in:
lib/ndr_dev_support/integration_testing/dsl.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



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/ndr_dev_support/integration_testing/dsl.rb', line 55

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
    raise ArgumentError, 'Unsupported window type!'
  end

  scopes << nil
  yield
  @scopes.pop
  switch_to_window(original)
end