1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Slight refactoring to Node#all

This commit is contained in:
Jonas Nicklas 2010-07-10 02:32:43 +02:00
parent 8bf63ee8e4
commit 2bd860d23a

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) }