Skip to content
This repository
Browse code

Fixing has_content?

* moved the gsub and strip into a function named normalize_whitespace
* added the call to has_no_content?
  • Loading branch information...
commit 1a553777aa16b88e2fdb2360074eb7b9484bfc2f 1 parent a74e821
Ryan Montgomery authored October 17, 2011

Showing 1 changed file with 8 additions and 2 deletions. Show diff stats Hide diff stats

  1. 10  lib/capybara/node/matchers.rb
10  lib/capybara/node/matchers.rb
@@ -181,7 +181,7 @@ def has_no_css?(path, options={})
181 181
       # @return [Boolean]             Whether it exists
182 182
       #
183 183
       def has_content?(content)
184  
-        has_xpath?(XPath::HTML.content(content.gsub(/\s+/, " ").strip))
  184
+        has_xpath?(XPath::HTML.content(normalize_whitespace(content)))
185 185
       end
186 186
 
187 187
       ##
@@ -193,7 +193,7 @@ def has_content?(content)
193 193
       # @return [Boolean]             Whether it exists
194 194
       #
195 195
       def has_no_content?(content)
196  
-        has_no_xpath?(XPath::HTML.content(content))
  196
+        has_no_xpath?(XPath::HTML.content(normalize_whitespace(content)))
197 197
       end
198 198
 
199 199
       ##
@@ -412,6 +412,12 @@ def split_options(options, key)
412 412
         options = options.dup
413 413
         [options, if options.has_key?(key) then {key => options.delete(key)} else {} end]
414 414
       end
  415
+      
  416
+      private
  417
+      
  418
+      def normalize_whitespace(text)
  419
+        text.gsub(/\s+/, " ").strip
  420
+      end
415 421
     end
416 422
   end
417 423
 end

0 notes on commit 1a55377

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