mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Update for latest xpath gem
This commit is contained in:
parent
c67dceb537
commit
b9dadbb833
5 changed files with 15 additions and 10 deletions
|
@ -9,7 +9,7 @@ PATH
|
|||
rack (>= 1.0.0)
|
||||
rack-test (>= 0.5.4)
|
||||
selenium-webdriver (>= 0.0.27)
|
||||
xpath (>= 0.1.0)
|
||||
xpath (~> 0.1.1)
|
||||
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
|
@ -51,7 +51,8 @@ GEM
|
|||
sinatra (1.0)
|
||||
rack (>= 1.0)
|
||||
weakling (0.0.4-java)
|
||||
xpath (0.1.0)
|
||||
xpath (0.1.1)
|
||||
nokogiri (~> 1.3)
|
||||
yard (0.6.1)
|
||||
|
||||
PLATFORMS
|
||||
|
@ -70,5 +71,5 @@ DEPENDENCIES
|
|||
rspec (>= 2.0.0.beta.22)
|
||||
selenium-webdriver (>= 0.0.27)
|
||||
sinatra (>= 0.9.4)
|
||||
xpath (>= 0.1.0)
|
||||
xpath (~> 0.1.1)
|
||||
yard (>= 0.5.8)
|
||||
|
|
|
@ -29,7 +29,7 @@ Gem::Specification.new do |s|
|
|||
s.add_runtime_dependency("selenium-webdriver", [">= 0.0.27"])
|
||||
s.add_runtime_dependency("rack", [">= 1.0.0"])
|
||||
s.add_runtime_dependency("rack-test", [">= 0.5.4"])
|
||||
s.add_runtime_dependency("xpath", [">= 0.1.0"])
|
||||
s.add_runtime_dependency("xpath", ["~> 0.1.1"])
|
||||
|
||||
s.add_development_dependency("sinatra", [">= 0.9.4"])
|
||||
s.add_development_dependency("rspec", [">= 2.0.0.beta.22"])
|
||||
|
|
|
@ -122,8 +122,7 @@ module Capybara
|
|||
def all(*args)
|
||||
options = if args.last.is_a?(Hash) then args.pop else {} end
|
||||
|
||||
selector = Capybara::Selector.normalize(*args)
|
||||
results = XPath::HTML.wrap(selector).map do |path|
|
||||
results = Capybara::Selector.normalize(*args).map do |path|
|
||||
base.find(path)
|
||||
end.flatten
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ module Capybara
|
|||
# @return [Boolean] If the selector exists
|
||||
#
|
||||
def has_css?(path, options={})
|
||||
has_xpath?(XPath::HTML.from_css(path), options)
|
||||
has_xpath?(XPath.css(path), options)
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -103,7 +103,7 @@ module Capybara
|
|||
# @return [Boolean]
|
||||
#
|
||||
def has_no_css?(path, options={})
|
||||
has_no_xpath?(XPath::HTML.from_css(path), options)
|
||||
has_no_xpath?(XPath.css(path), options)
|
||||
end
|
||||
|
||||
##
|
||||
|
|
|
@ -16,13 +16,18 @@ module Capybara
|
|||
end
|
||||
|
||||
def normalize(name_or_locator, locator=nil)
|
||||
if locator
|
||||
xpath = if locator
|
||||
all[name_or_locator.to_sym].call(locator)
|
||||
else
|
||||
selector = all.values.find { |s| s.match?(name_or_locator) }
|
||||
selector ||= all[Capybara.default_selector]
|
||||
selector.call(name_or_locator)
|
||||
end
|
||||
if xpath.respond_to?(:to_xpaths)
|
||||
xpath.to_xpaths
|
||||
else
|
||||
[xpath.to_s].flatten
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -43,5 +48,5 @@ module Capybara
|
|||
end
|
||||
|
||||
Capybara::Selector.add(:xpath) { |xpath| xpath }
|
||||
Capybara::Selector.add(:css) { |css| XPath::HTML.from_css(css) }
|
||||
Capybara::Selector.add(:css) { |css| XPath.css(css) }
|
||||
Capybara::Selector.add(:id, :for => Symbol) { |id| XPath.descendant(:*)[XPath.attr(:id) == id.to_s] }
|
||||
|
|
Loading…
Add table
Reference in a new issue