Module: Capybara::Helpers Private
Relationships & Source Files | |
Namespace Children | |
Classes:
| |
Defined in: | lib/capybara/helpers.rb |
Class Method Summary
-
.declension(singular, plural, count)
Internal use only
mod_func
A poor man’s
pluralize
. - .filter_backtrace(trace) Internal use only mod_func
-
.inject_asset_host(html, host: Capybara.asset_host) ⇒ String
Internal use only
mod_func
Injects a
<base>
tag into the given HTML code, pointing to asset_host. -
.monotonic_time
mod_func
See additional method definition at line 89.
- .normalize_whitespace(text) ⇒ String deprecated Internal use only mod_func Deprecated.
- .timer(expire_in:) Internal use only mod_func
-
.to_regexp(text, exact: false, all_whitespace: false, options: nil) ⇒ Regexp
Internal use only
mod_func
Escapes any characters that would have special meaning in a regexp if text is not a regexp.
- .warn(message, uplevel: 1) Internal use only mod_func
Class Method Details
.declension(singular, plural, count) (mod_func)
A poor man’s pluralize
. Given two declensions, one singular and one plural, as well as a count, this will pick the correct declension. This way we can generate grammatically correct error message.
# File 'lib/capybara/helpers.rb', line 69
def declension(singular, plural, count) count == 1 ? singular : plural end
.filter_backtrace(trace) (mod_func)
[ GitHub ]# File 'lib/capybara/helpers.rb', line 73
def filter_backtrace(trace) return 'No backtrace' unless trace filter = %r{lib/capybara/|lib/rspec/|lib/minitest/|delegate.rb} new_trace = trace.take_while { |line| line !~ filter } new_trace = trace.grep_v(filter) if new_trace.empty? new_trace = trace.dup if new_trace.empty? new_trace.first.split(':in ', 2).first end
.inject_asset_host(html, host: Capybara.asset_host) ⇒ String
(mod_func)
Injects a <base>
tag into the given Capybara.HTML code, pointing to asset_host.
.monotonic_time (mod_func)
See additional method definition at line 89.
See additional method definition at line 91.
See additional method definition at line 93.
# File 'lib/capybara/helpers.rb', line 95
def monotonic_time; Process.clock_gettime Process::CLOCK_MONOTONIC_RAW; end
.normalize_whitespace(text) ⇒ String
(mod_func)
Normalizes whitespace space by stripping leading and trailing whitespace and replacing sequences of whitespace characters with a single space.
.timer(expire_in:) (mod_func)
[ GitHub ]
.to_regexp(text, exact: false, all_whitespace: false, options: nil) ⇒ Regexp
(mod_func)
Escapes any characters that would have special meaning in a regexp if text is not a regexp
# File 'lib/capybara/helpers.rb', line 32
def to_regexp(text, exact: false, all_whitespace: false, options: nil) return text if text.is_a?(Regexp) escaped = Regexp.escape(text) escaped = escaped.gsub('\\ ', '[[:blank:]]') if all_whitespace escaped = "\\A#{escaped}\\z" if exact Regexp.new(escaped, ) end
.warn(message, uplevel: 1) (mod_func)
[ GitHub ]# File 'lib/capybara/helpers.rb', line 84
def warn(, uplevel: 1) Kernel.warn(, uplevel: uplevel) end