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

default selector no longer interferes with has_xpath

This commit is contained in:
Jonas Nicklas 2010-01-28 22:47:35 +01:00
parent bfc846267e
commit 0f2e2d3164
3 changed files with 18 additions and 2 deletions

View file

@ -132,7 +132,7 @@ module Capybara
def has_xpath?(path, options={})
wait_conditionally_until do
results = all(path, options)
results = all(:xpath, path, options)
if options[:count]
results.size == options[:count]
@ -146,7 +146,7 @@ module Capybara
def has_no_xpath?(path, options={})
wait_conditionally_until do
results = all(path, options)
results = all(:xpath, path, options)
if options[:count]
results.size != options[:count]

View file

@ -16,6 +16,11 @@ shared_examples_for "has_xpath" do
@session.should_not have_xpath("//p[contains(.,'thisstringisnotonpage')]")
end
it "should use xpath even if default selector is CSS" do
Capybara.default_selector = :css
@session.should_not have_xpath("//p//a[@id='doesnotexist']")
end
it "should respect scopes" do
@session.within "//p[@id='first']" do
@session.should have_xpath("//a[@id='foo']")
@ -72,6 +77,11 @@ shared_examples_for "has_xpath" do
@session.should have_no_xpath("//p[contains(.,'thisstringisnotonpage')]")
end
it "should use xpath even if default selector is CSS" do
Capybara.default_selector = :css
@session.should have_no_xpath("//p//a[@id='doesnotexist']")
end
it "should respect scopes" do
@session.within "//p[@id='first']" do
@session.should_not have_no_xpath("//a[@id='foo']")

View file

@ -19,3 +19,9 @@ require 'session_without_headers_support_spec'
alias :running :lambda
Capybara.default_wait_time = 1 # less timeout so tests run faster
Spec::Runner.configure do |config|
config.after do
Capybara.default_selector = :xpath
end
end