Permalink
Browse files

Fixing has_content?

* moved the gsub and strip into a function named normalize_whitespace
* added the call to has_no_content?
  • Loading branch information...
1 parent a74e821 commit 1a553777aa16b88e2fdb2360074eb7b9484bfc2f @rmontgomery429 rmontgomery429 committed Oct 17, 2011
Showing with 8 additions and 2 deletions.
  1. +8 −2 lib/capybara/node/matchers.rb
@@ -181,7 +181,7 @@ def has_no_css?(path, options={})
# @return [Boolean] Whether it exists
#
def has_content?(content)
- has_xpath?(XPath::HTML.content(content.gsub(/\s+/, " ").strip))
+ has_xpath?(XPath::HTML.content(normalize_whitespace(content)))
end
##
@@ -193,7 +193,7 @@ def has_content?(content)
# @return [Boolean] Whether it exists
#
def has_no_content?(content)
- has_no_xpath?(XPath::HTML.content(content))
+ has_no_xpath?(XPath::HTML.content(normalize_whitespace(content)))
end
##
@@ -412,6 +412,12 @@ def split_options(options, key)
options = options.dup
[options, if options.has_key?(key) then {key => options.delete(key)} else {} end]
end
+
+ private
+
+ def normalize_whitespace(text)
+ text.gsub(/\s+/, " ").strip
+ end
end
end
end

0 comments on commit 1a55377

Please sign in to comment.