Slight refactoring to Node#all

This commit is contained in:
Jonas Nicklas 2010-07-10 02:32:43 +02:00
parent 8bf63ee8e4
commit 2bd860d23a
1 changed files with 4 additions and 9 deletions

View File

@ -37,19 +37,14 @@ module Capybara
base.find(path)
end.flatten
if options[:text]
if text = options[:text]
text = Regexp.escape(text) unless text.kind_of?(Regexp)
if options[:text].kind_of?(Regexp)
regexp = options[:text]
else
regexp = Regexp.escape(options[:text])
end
results = results.select { |n| n.text.match(regexp) }
results = results.select { |node| node.text.match(text) }
end
if options[:visible] or Capybara.ignore_hidden_elements
results = results.select { |n| n.visible? }
results = results.select { |node| node.visible? }
end
results.map { |n| Capybara::Element.new(self, n) }