Module: NdrDevSupport::IntegrationTesting::DSL
- Defined in:
- lib/ndr_dev_support/integration_testing/dsl.rb
Overview
Additional integration testing DSL:
Defined Under Namespace
Modules: SessionExtensions
Instance Method Summary collapse
-
#clear_headless_session! ⇒ Object
Instruct the headless browser to clear its session:.
-
#delete_all_cookies! ⇒ Object
Get the headless browser to delete all of the cookies for the current page without resetting:.
- #find_new(*args, **options) ⇒ Object
-
#within_modal(selector: '#modal', remain: false) ⇒ Object
Wrap up interacting with modals.
Instance Method Details
#clear_headless_session! ⇒ Object
Instruct the headless browser to clear its session:
8 9 10 |
# File 'lib/ndr_dev_support/integration_testing/dsl.rb', line 8 def clear_headless_session! page.driver.reset! end |
#delete_all_cookies! ⇒ Object
Get the headless browser to delete all of the cookies for the current page without resetting:
14 15 16 17 18 |
# File 'lib/ndr_dev_support/integration_testing/dsl.rb', line 14 def page.driver..each_key do |name| page.driver.(name) end end |
#find_new(*args, **options) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ndr_dev_support/integration_testing/dsl.rb', line 32 def find_new(*args, **) # There is no point waiting to see there are no existing matches: = { wait: 0 }.merge() prior_matches = find_all(*args, **) yield # We expect exactly one new match as a result of the interaction: = { count: prior_matches.length + 1 } current_matches = find_all(*args, **) current_matches.without(*prior_matches).first end |
#within_modal(selector: '#modal', remain: false) ⇒ Object
Wrap up interacting with modals. The assumption is that the modal should be gone one the interaction is complete (as this is a good proxy for a triggered AJAX request to have completed, and therefore a signal for capybara to wait for); if this is not the case, pass ‘remain: true` to signal that the modal should remain active.
25 26 27 28 29 30 |
# File 'lib/ndr_dev_support/integration_testing/dsl.rb', line 25 def within_modal(selector: '#modal', remain: false) within(selector) { yield } = "modal was #{'not ' unless remain} expected to remain visible!" assert(remain ? has_selector?(selector) : has_no_selector?(selector), ) end |