optional locators

This commit is contained in:
Thomas Walpole 2016-10-03 14:50:23 -07:00
parent fd6a3d0a75
commit 5484a617fa
2 changed files with 15 additions and 15 deletions

View File

@ -268,7 +268,7 @@ module Capybara
# @option options [String, Regexp] :href The value the href attribute must be
# @return [Boolean] Whether it exists
#
def has_link?(locator, **options, &optional_filter_block)
def has_link?(locator=nil, **options, &optional_filter_block)
has_selector?(:link, locator, options, &optional_filter_block)
end
@ -280,7 +280,7 @@ module Capybara
# @param (see Capybara::Node::Finders#has_link?)
# @return [Boolean] Whether it doesn't exist
#
def has_no_link?(locator, **options, &optional_filter_block)
def has_no_link?(locator=nil, **options, &optional_filter_block)
has_no_selector?(:link, locator, options, &optional_filter_block)
end
@ -292,7 +292,7 @@ module Capybara
# @param [String] locator The text, value or id of a button to check for
# @return [Boolean] Whether it exists
#
def has_button?(locator, **options, &optional_filter_block)
def has_button?(locator=nil, **options, &optional_filter_block)
has_selector?(:button, locator, options, &optional_filter_block)
end
@ -304,7 +304,7 @@ module Capybara
# @param [String] locator The text, value or id of a button to check for
# @return [Boolean] Whether it doesn't exist
#
def has_no_button?(locator, **options, &optional_filter_block)
def has_no_button?(locator=nil, **options, &optional_filter_block)
has_no_selector?(:button, locator, options, &optional_filter_block)
end
@ -330,7 +330,7 @@ module Capybara
# @option options [String] :type The type attribute of the field
# @return [Boolean] Whether it exists
#
def has_field?(locator, **options, &optional_filter_block)
def has_field?(locator=nil, **options, &optional_filter_block)
has_selector?(:field, locator, options, &optional_filter_block)
end
@ -344,7 +344,7 @@ module Capybara
# @option options [String] :type The type attribute of the field
# @return [Boolean] Whether it doesn't exist
#
def has_no_field?(locator, **options, &optional_filter_block)
def has_no_field?(locator=nil, **options, &optional_filter_block)
has_no_selector?(:field, locator, options, &optional_filter_block)
end
@ -429,7 +429,7 @@ module Capybara
# @option options [String, Array] :with_selected Partial set of options which should minimally be selected
# @return [Boolean] Whether it exists
#
def has_select?(locator, **options, &optional_filter_block)
def has_select?(locator=nil, **options, &optional_filter_block)
has_selector?(:select, locator, options, &optional_filter_block)
end
@ -441,7 +441,7 @@ module Capybara
# @param (see Capybara::Node::Matchers#has_select?)
# @return [Boolean] Whether it doesn't exist
#
def has_no_select?(locator, **options, &optional_filter_block)
def has_no_select?(locator=nil, **options, &optional_filter_block)
has_no_selector?(:select, locator, options, &optional_filter_block)
end
@ -455,7 +455,7 @@ module Capybara
# @param [String] locator The id or caption of a table
# @return [Boolean] Whether it exist
#
def has_table?(locator, **options, &optional_filter_block)
def has_table?(locator=nil, **options, &optional_filter_block)
has_selector?(:table, locator, options, &optional_filter_block)
end
@ -467,7 +467,7 @@ module Capybara
# @param (see Capybara::Node::Matchers#has_table?)
# @return [Boolean] Whether it doesn't exist
#
def has_no_table?(locator, **options, &optional_filter_block)
def has_no_table?(locator=nil, **options, &optional_filter_block)
has_no_selector?(:table, locator, options, &optional_filter_block)
end

View File

@ -301,19 +301,19 @@ module Capybara
# RSpec matcher for links
# See {Capybara::Node::Matchers#has_link?}
def have_link(locator, **options, &optional_filter_block)
def have_link(locator=nil, **options, &optional_filter_block)
HaveSelector.new(:link, locator, options, &optional_filter_block)
end
# RSpec matcher for buttons
# See {Capybara::Node::Matchers#has_button?}
def have_button(locator, **options, &optional_filter_block)
def have_button(locator=nil, **options, &optional_filter_block)
HaveSelector.new(:button, locator, options, &optional_filter_block)
end
# RSpec matcher for links
# See {Capybara::Node::Matchers#has_field?}
def have_field(locator, **options, &optional_filter_block)
def have_field(locator=nil, **options, &optional_filter_block)
HaveSelector.new(:field, locator, options, &optional_filter_block)
end
@ -331,13 +331,13 @@ module Capybara
# RSpec matcher for select elements
# See {Capybara::Node::Matchers#has_select?}
def have_select(locator, **options, &optional_filter_block)
def have_select(locator=nil, **options, &optional_filter_block)
HaveSelector.new(:select, locator, options, &optional_filter_block)
end
# RSpec matcher for table elements
# See {Capybara::Node::Matchers#has_table?}
def have_table(locator, **options, &optional_filter_block)
def have_table(locator=nil, **options, &optional_filter_block)
HaveSelector.new(:table, locator, options, &optional_filter_block)
end