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

Add exact config option

This commit is contained in:
Jonas Nicklas 2013-02-15 20:02:15 +01:00
parent aa3d3e1ead
commit 83570f3ece
4 changed files with 12 additions and 3 deletions

View file

@ -16,7 +16,7 @@ module Capybara
class << self
attr_accessor :asset_root, :app_host, :run_server, :default_host, :always_include_port
attr_accessor :server_host, :server_port
attr_accessor :server_host, :server_port, :exact
attr_accessor :default_selector, :default_wait_time, :ignore_hidden_elements
attr_accessor :save_and_open_page_path, :automatic_reload
attr_writer :default_driver, :current_driver, :javascript_driver, :session_name

View file

@ -11,6 +11,10 @@ module Capybara
@options[:visible] = Capybara.ignore_hidden_elements
end
unless options.has_key?(:exact)
@options[:exact] = Capybara.exact
end
if args[0].is_a?(Symbol)
@selector = Selector.all[args[0]]
@locator = args[1]
@ -27,7 +31,6 @@ module Capybara
@xpath = @xpath.to_s
end
assert_valid_keys!
end

View file

@ -127,7 +127,12 @@ Capybara::SpecHelper.spec '#find' do
end
it "defaults to `Capybara.exact`" do
Capybara.exact = true
expect do
@session.find(:xpath, XPath.descendant(:input)[XPath.attr(:id).is("est_fiel")])
end.to raise_error(Capybara::ElementNotFound)
Capybara.exact = false
@session.find(:xpath, XPath.descendant(:input)[XPath.attr(:id).is("est_fiel")])
end
end

View file

@ -19,6 +19,7 @@ module Capybara
Capybara.app_host = nil
Capybara.default_selector = :xpath
Capybara.default_wait_time = 1
Capybara.exact = false
end
def filter(requires, metadata)