Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Replace ugly regex with POSIX class

`[[:space:]]` works like `\s` in regexes, except it is encoding aware.
  • Loading branch information...
commit 8852e4dc20db420e7e012b3265cbf4d369a761ba 1 parent 8873f8f
@bencates bencates authored
Showing with 1 addition and 4 deletions.
  1. +1 −4 lib/capybara/helpers.rb
View
5 lib/capybara/helpers.rb
@@ -13,10 +13,7 @@ class << self
# @return [String] Normalized text
#
def normalize_whitespace(text)
- # http://en.wikipedia.org/wiki/Whitespace_character#Unicode
- # We should have a better reference.
- # See also http://stackoverflow.com/a/11758133/525872
- text.to_s.gsub(/[\s\u0085\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000]+/, ' ').strip
+ text.to_s.gsub(/[[:space:]]+/, ' ').strip
end
##

8 comments on commit 8852e4d

@dmtroyer

Is this related to issue 900?

@jnicklas
Owner

Probably, yes.

@abriening

This also fixes an issue with encoding and 1.8.7:

Capybara::Helpers.normalize_whitespace('test')
=> ""

This was causing any "has_content?" to return true.

@take

This commit isn't included in capybara v2.0.2, so if ur using ruby 1.8.7, u need to use edge to enable has_content? method.

@jnicklas
Owner

Capybara 2.0 does not support 1.8.7, stay on 1.x or upgrade to a newer Ruby version.

@take

Capybara 2.0 does not support 1.8.7, stay on 1.x or upgrade to a newer Ruby version.

oh really, thx!

@abriening

I quickly found out that 2.x it doesn't support ruby 1.8.7 at all.
Unfortunately, the gemspec won't specify the ruby version dependency until the next release (2.0.3):
82e0142

A good time to upgrade to 1.9 :thumbsup:

@take

oo thx for telling me :)

Please sign in to comment.
Something went wrong with that request. Please try again.