From 7dba3bb9b9f2aaad7358f578f0b1aceae4247f5b Mon Sep 17 00:00:00 2001 From: Jonas Nicklas Date: Fri, 12 Mar 2010 20:13:10 +0100 Subject: [PATCH] Put most relevant methods at top of xpath class --- lib/capybara/xpath.rb | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/capybara/xpath.rb b/lib/capybara/xpath.rb index bf23778f..b4b87fbf 100644 --- a/lib/capybara/xpath.rb +++ b/lib/capybara/xpath.rb @@ -28,6 +28,22 @@ module Capybara @paths = paths end + def scope(scope) + XPath.new(*paths.map { |p| scope + p }) + end + + def to_s + @paths.join(' | ') + end + + def append(path) + XPath.new(*[@paths, XPath.wrap(path).paths].flatten) + end + + def prepend(path) + XPath.new(*[XPath.wrap(path).paths, @paths].flatten) + end + def from_css(css) append(Nokogiri::CSS.xpath_for(css).first) end @@ -96,22 +112,6 @@ module Capybara add_field(locator, "//select", options) end - def scope(scope) - XPath.new(*paths.map { |p| scope + p }) - end - - def to_s - @paths.join(' | ') - end - - def append(path) - XPath.new(*[@paths, XPath.wrap(path).paths].flatten) - end - - def prepend(path) - XPath.new(*[XPath.wrap(path).paths, @paths].flatten) - end - def checkbox(locator, options={}) input_field(:checkbox, locator, options) end