Module: Softwear::Lib::Spec::CapybaraHelpers
- Defined in:
- lib/softwear/lib/spec.rb
Instance Method Summary collapse
- #accept_alert ⇒ Object
- #dismiss_alert ⇒ Object
- #finished_all_ajax_requests? ⇒ Boolean
- #wait_for_ajax ⇒ Object
- #wait_for_jquery ⇒ Object
- #wait_for_redirect ⇒ Object
Instance Method Details
#accept_alert ⇒ Object
36 37 38 39 |
# File 'lib/softwear/lib/spec.rb', line 36 def accept_alert page.evaluate_script('window.confirm = function() { return true; }') yield end |
#dismiss_alert ⇒ Object
41 42 43 44 45 46 |
# File 'lib/softwear/lib/spec.rb', line 41 def dismiss_alert page.evaluate_script('window.confirm = function() { return false; }') yield # Restore existing default page.evaluate_script('window.confirm = function() { return true; }') end |
#finished_all_ajax_requests? ⇒ Boolean
19 20 21 |
# File 'lib/softwear/lib/spec.rb', line 19 def finished_all_ajax_requests? page.evaluate_script('jQuery.active').zero? end |
#wait_for_ajax ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/softwear/lib/spec.rb', line 8 def wait_for_ajax begin Timeout.timeout(.default_wait_time) do wait_for_jquery loop until finished_all_ajax_requests? end rescue sleep 0.1 end end |
#wait_for_jquery ⇒ Object
30 31 32 33 34 |
# File 'lib/softwear/lib/spec.rb', line 30 def wait_for_jquery until page.evaluate_script('jQuery.active') == 0 sleep(0.1) end end |
#wait_for_redirect ⇒ Object
23 24 25 26 27 28 |
# File 'lib/softwear/lib/spec.rb', line 23 def wait_for_redirect original_url = current_path until current_path != original_url sleep(0.1) end end |