Module: Utilities
- Included in:
- BaseInterface, Browser
- Defined in:
- lib/rutl/utilities.rb
Overview
A catch-all bag for stuff I don’t have elsewhere yet.
Constant Summary collapse
- POLL_SLEEP_TIME =
0.1- DEFAULT_TIMEOUT =
5
Instance Method Summary collapse
-
#await(lamb, timeout = DEFAULT_TIMEOUT, poll_sleep_time = POLL_SLEEP_TIME) ⇒ Object
The lambda passed to await should return false if thing not found and something truthy if found.
- #class_info(object) ⇒ Object
-
#location ⇒ Object
Just call “caller” with no args for stack trace.
- #page?(checkme) ⇒ Boolean
- #raise_if_not_page(page) ⇒ Object
Instance Method Details
#await(lamb, timeout = DEFAULT_TIMEOUT, poll_sleep_time = POLL_SLEEP_TIME) ⇒ Object
The lambda passed to await should return false if thing not found and something truthy if found
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rutl/utilities.rb', line 12 def await(lamb, timeout = DEFAULT_TIMEOUT, poll_sleep_time = POLL_SLEEP_TIME) Timeout.timeout(timeout) do loop do result = lamb.call return result if result # rubocop:disable Style/SleepCop sleep poll_sleep_time # rubocop:enable Style/SleepCop end end end |
#class_info(object) ⇒ Object
24 25 26 27 28 |
# File 'lib/rutl/utilities.rb', line 24 def class_info(object) result = "CLASS: #{object.class}" result += "\nmethods: #{(object.methods - Class.methods).sort}\n" result end |
#location ⇒ Object
Just call “caller” with no args for stack trace.
31 32 33 |
# File 'lib/rutl/utilities.rb', line 31 def location caller(1..1).first end |
#page?(checkme) ⇒ Boolean
35 36 37 38 39 40 |
# File 'lib/rutl/utilities.rb', line 35 def page?(checkme) checkme.ancestors.include?(BasePage) rescue NoMethodError # This isn't a even a class. It's no page! false end |
#raise_if_not_page(page) ⇒ Object
42 43 44 |
# File 'lib/rutl/utilities.rb', line 42 def raise_if_not_page(page) raise "NOT A PAGE: #{page}. Ancestors: #{page.ancestors}" unless page?(page) end |