Module: ConfirmationHelpers
- Defined in:
- lib/decidim/dev/test/rspec_support/confirmation_helpers.rb
Overview
Helpers that get automatically included in component specs.
Instance Method Summary collapse
-
#accept_confirm(_text = nil, **_options) ⇒ Object
Overrides the Capybara default accept_confirm because we have replaced the system’s own confirmation modal with foundation based modal.
-
#accept_page_unload(text = nil, **options, &blk) ⇒ Object
Used to accept the “onbeforeunload” event’s normal browser confirm modal as this cannot be overridden.
-
#dismiss_confirm(_text = nil, **_options) ⇒ Object
Overrides the Capybara default dismiss_confirm because we have replaced the system’s own confirmation modal with foundation based modal.
-
#dismiss_page_unload(text = nil, **options, &blk) ⇒ Object
Used to dismiss the “onbeforeunload” event’s normal browser confirm modal as this cannot be overridden.
Instance Method Details
#accept_confirm(_text = nil, **_options) ⇒ Object
Overrides the Capybara default accept_confirm because we have replaced the system’s own confirmation modal with foundation based modal.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/decidim/dev/test/rspec_support/confirmation_helpers.rb', line 10 def accept_confirm(_text = nil, **) yield if block_given? # The test can already be "within", so find the body using xpath = nil body = find(:xpath, "/html/body") within(body.find(".confirm-reveal")) do = find(".confirm-modal-content").text find("a.button[data-confirm-ok]").click end end |
#accept_page_unload(text = nil, **options, &blk) ⇒ Object
Used to accept the “onbeforeunload” event’s normal browser confirm modal as this cannot be overridden. Original confirm dismiss implementation in Capybara.
46 47 48 |
# File 'lib/decidim/dev/test/rspec_support/confirmation_helpers.rb', line 46 def accept_page_unload(text = nil, **, &blk) page.send(:accept_modal, :confirm, text, , &blk) end |
#dismiss_confirm(_text = nil, **_options) ⇒ Object
Overrides the Capybara default dismiss_confirm because we have replaced the system’s own confirmation modal with foundation based modal.
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/decidim/dev/test/rspec_support/confirmation_helpers.rb', line 29 def dismiss_confirm(_text = nil, **) yield if block_given? # The test can already be "within", so find the body using xpath = nil body = find(:xpath, "/html/body") within(body.find(".confirm-reveal")) do = find(".confirm-modal-content").text find("a.button[data-confirm-cancel]").click end end |
#dismiss_page_unload(text = nil, **options, &blk) ⇒ Object
Used to dismiss the “onbeforeunload” event’s normal browser confirm modal as this cannot be overridden. Original confirm dismiss implementation in Capybara.
53 54 55 |
# File 'lib/decidim/dev/test/rspec_support/confirmation_helpers.rb', line 53 def dismiss_page_unload(text = nil, **, &blk) page.send(:dismiss_modal, :confirm, text, , &blk) end |