From 2bd860d23a403b6388cb3844174e251c1747ed7a Mon Sep 17 00:00:00 2001 From: Jonas Nicklas Date: Sat, 10 Jul 2010 02:32:43 +0200 Subject: [PATCH] Slight refactoring to Node#all --- lib/capybara/node/finders.rb | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/capybara/node/finders.rb b/lib/capybara/node/finders.rb index f830e14e..13dd377a 100644 --- a/lib/capybara/node/finders.rb +++ b/lib/capybara/node/finders.rb @@ -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) }