Sha256: 4fbdb53881e56bbd0f4c006e94339a1e7a0597c73a6e0f8f94e51fcf5c581e7a
Contents?: true
Size: 1.11 KB
Versions: 4
Compression:
Stored size: 1.11 KB
Contents
# # A catch-all bag for stuff I don't have elsewhere yet. # module Utilities require 'timeout' POLL_SLEEP_TIME = 0.1 DEFAULT_TIMEOUT = 5 # The lambda passed to await should return false if thing not found # and something truthy if found 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 def class_info(object) result = "CLASS: #{object.class}" result += "\nmethods: #{(object.methods - Class.methods).sort}\n" result end # Just call "caller" with no args for stack trace. def location caller(1..1).first end def page?(checkme) checkme.ancestors.include?(BasePage) rescue NoMethodError # This isn't a even a class. It's no page! false end def raise_if_not_page(page) raise "NOT A PAGE: #{page}. Ancestors: #{page.ancestors}" unless page?(page) end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
rutl-0.3.0 | lib/rutl/utilities.rb |
rutl-0.2.1 | lib/rutl/utilities.rb |
rutl-0.2.0 | lib/rutl/utilities.rb |
rutl-0.1.4 | lib/rutl/utilities.rb |