Module: Capybara::Helpers
- Defined in:
- lib/capybara/helpers.rb
Class Method Summary collapse
-
.normalize_whitespace(text) ⇒ String
Normalizes whitespace space by stripping leading and trailing whitespace and replacing sequences of whitespace characters with a single space.
-
.to_regexp(text) ⇒ String
Escapes any characters that would have special meaning in a regexp if text is not a regexp.
Class Method Details
.normalize_whitespace(text) ⇒ String
Normalizes whitespace space by stripping leading and trailing whitespace and replacing sequences of whitespace characters with a single space.
15 16 17 |
# File 'lib/capybara/helpers.rb', line 15 def normalize_whitespace(text) text.to_s.gsub(/[[:space:]]+/, ' ').strip end |
.to_regexp(text) ⇒ String
Escapes any characters that would have special meaning in a regexp if text is not a regexp
27 28 29 |
# File 'lib/capybara/helpers.rb', line 27 def to_regexp(text) text.is_a?(Regexp) ? text : Regexp.escape(normalize_whitespace(text)) end |