Module: E2E::DSL
Instance Method Summary collapse
- #click_button_and_wait_for_flash(value, text = nil, type: nil, timeout: E2E.config.wait_timeout, interval: 0.05, **options) ⇒ Object
- #click_button_and_wait_for_path(value, expected_path, timeout: E2E.config.wait_timeout, interval: 0.05, **options) ⇒ Object
- #click_button_and_wait_for_text(value, text, timeout: E2E.config.wait_timeout, interval: 0.05, **options) ⇒ Object
- #click_link_and_wait_for_flash(value, text = nil, type: nil, timeout: E2E.config.wait_timeout, interval: 0.05, **options) ⇒ Object
- #click_link_and_wait_for_path(value, expected_path, timeout: E2E.config.wait_timeout, interval: 0.05, **options) ⇒ Object
- #click_link_and_wait_for_text(value, text, timeout: E2E.config.wait_timeout, interval: 0.05, **options) ⇒ Object
- #page ⇒ Object
-
#wait_for(timeout: E2E.config.wait_timeout, interval: 0.05, message: "Timed out waiting for condition") ⇒ Object
Waits until the provided block returns a truthy value.
- #wait_for_current_path(expected_path, timeout: E2E.config.wait_timeout, interval: 0.05) ⇒ Object
- #wait_for_flash(text = nil, type: nil, timeout: E2E.config.wait_timeout, interval: 0.05) ⇒ Object
- #wait_for_text(text, timeout: E2E.config.wait_timeout, interval: 0.05) ⇒ Object
Instance Method Details
#click_button_and_wait_for_flash(value, text = nil, type: nil, timeout: E2E.config.wait_timeout, interval: 0.05, **options) ⇒ Object
84 85 86 87 |
# File 'lib/e2e/dsl.rb', line 84 def (value, text = nil, type: nil, timeout: E2E.config.wait_timeout, interval: 0.05, **) (value, **) wait_for_flash(text, type: type, timeout: timeout, interval: interval) end |
#click_button_and_wait_for_path(value, expected_path, timeout: E2E.config.wait_timeout, interval: 0.05, **options) ⇒ Object
74 75 76 77 |
# File 'lib/e2e/dsl.rb', line 74 def (value, expected_path, timeout: E2E.config.wait_timeout, interval: 0.05, **) (value, **) wait_for_current_path(expected_path, timeout: timeout, interval: interval) end |
#click_button_and_wait_for_text(value, text, timeout: E2E.config.wait_timeout, interval: 0.05, **options) ⇒ Object
64 65 66 67 |
# File 'lib/e2e/dsl.rb', line 64 def (value, text, timeout: E2E.config.wait_timeout, interval: 0.05, **) (value, **) wait_for_text(text, timeout: timeout, interval: interval) end |
#click_link_and_wait_for_flash(value, text = nil, type: nil, timeout: E2E.config.wait_timeout, interval: 0.05, **options) ⇒ Object
89 90 91 92 |
# File 'lib/e2e/dsl.rb', line 89 def click_link_and_wait_for_flash(value, text = nil, type: nil, timeout: E2E.config.wait_timeout, interval: 0.05, **) click_link(value, **) wait_for_flash(text, type: type, timeout: timeout, interval: interval) end |
#click_link_and_wait_for_path(value, expected_path, timeout: E2E.config.wait_timeout, interval: 0.05, **options) ⇒ Object
79 80 81 82 |
# File 'lib/e2e/dsl.rb', line 79 def click_link_and_wait_for_path(value, expected_path, timeout: E2E.config.wait_timeout, interval: 0.05, **) click_link(value, **) wait_for_current_path(expected_path, timeout: timeout, interval: interval) end |
#click_link_and_wait_for_text(value, text, timeout: E2E.config.wait_timeout, interval: 0.05, **options) ⇒ Object
69 70 71 72 |
# File 'lib/e2e/dsl.rb', line 69 def click_link_and_wait_for_text(value, text, timeout: E2E.config.wait_timeout, interval: 0.05, **) click_link(value, **) wait_for_text(text, timeout: timeout, interval: interval) end |
#wait_for(timeout: E2E.config.wait_timeout, interval: 0.05, message: "Timed out waiting for condition") ⇒ Object
Waits until the provided block returns a truthy value. Raises E2E::Error on timeout for easier failure diagnostics.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/e2e/dsl.rb', line 18 def wait_for(timeout: E2E.config.wait_timeout, interval: 0.05, message: "Timed out waiting for condition") result = nil found = E2E.wait_until(timeout: timeout, interval: interval) do result = yield result end raise E2E::Error, unless found result end |
#wait_for_current_path(expected_path, timeout: E2E.config.wait_timeout, interval: 0.05) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/e2e/dsl.rb', line 40 def wait_for_current_path(expected_path, timeout: E2E.config.wait_timeout, interval: 0.05) wait_for( timeout: timeout, interval: interval, message: "Expected current path to be #{expected_path.inspect} within #{timeout} seconds" ) do current_path_matches?(expected_path) end end |
#wait_for_flash(text = nil, type: nil, timeout: E2E.config.wait_timeout, interval: 0.05) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/e2e/dsl.rb', line 50 def wait_for_flash(text = nil, type: nil, timeout: E2E.config.wait_timeout, interval: 0.05) wait_for( timeout: timeout, interval: interval, message: (text, type, timeout) ) do flashes = visible_flashes(type: type) next false if flashes.empty? next true if text.nil? flashes.any? { |flash_text| text_matches?(flash_text, text) } end end |
#wait_for_text(text, timeout: E2E.config.wait_timeout, interval: 0.05) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/e2e/dsl.rb', line 30 def wait_for_text(text, timeout: E2E.config.wait_timeout, interval: 0.05) wait_for( timeout: timeout, interval: interval, message: "Expected page to have text #{text.inspect} within #{timeout} seconds" ) do text_matches?(page.text, text) end end |