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)  ⇒ 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)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Used to accept the “onbeforeunload” event’s normal browser confirm modal as this cannot be overridden.
 - 
  
    
      #dismiss_confirm(_text = nil)  ⇒ 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)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Used to dismiss the “onbeforeunload” event’s normal browser confirm modal as this cannot be overridden.
 
Instance Method Details
#accept_confirm(_text = nil) ⇒ 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 23 24  | 
    
      # 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 body = find(:xpath, "/html/body") confirm_selector = "[data-confirm-modal-content]" = nil within body do = find(confirm_selector).text find("[data-confirm-ok]").click end end  | 
  
#accept_page_unload(text = nil, **options) ⇒ Object
Used to accept the “onbeforeunload” event’s normal browser confirm modal as this cannot be overridden. Original confirm dismiss implementation in Capybara.
      50 51 52  | 
    
      # File 'lib/decidim/dev/test/rspec_support/confirmation_helpers.rb', line 50 def accept_page_unload(text = nil, **, &) page.send(:accept_modal, :confirm, text, , &) end  | 
  
#dismiss_confirm(_text = nil) ⇒ Object
Overrides the Capybara default dismiss_confirm because we have replaced the system’s own confirmation modal with foundation based modal.
      31 32 33 34 35 36 37 38 39 40 41 42 43 44 45  | 
    
      # File 'lib/decidim/dev/test/rspec_support/confirmation_helpers.rb', line 31 def dismiss_confirm(_text = nil) yield if block_given? # The test can already be "within", so find the body using xpath body = find(:xpath, "/html/body") confirm_selector = "[data-confirm-modal-content]" = nil within body do = find(confirm_selector).text find("[data-confirm-cancel]").click end end  | 
  
#dismiss_page_unload(text = nil, **options) ⇒ Object
Used to dismiss the “onbeforeunload” event’s normal browser confirm modal as this cannot be overridden. Original confirm dismiss implementation in Capybara.
      57 58 59  | 
    
      # File 'lib/decidim/dev/test/rspec_support/confirmation_helpers.rb', line 57 def dismiss_page_unload(text = nil, **, &) page.send(:dismiss_modal, :confirm, text, , &) end  |