module Capybara::RSpecMatchers

def become_closed(**options)

Options Hash: (**options)
  • :wait (Numeric) -- Maximum wait time

Parameters:
  • options (Hash) -- optional param
def become_closed(**options)
  BecomeClosed.new(options)
end

def have_all_of_selectors(*args, &optional_filter_block)

See {Capybara::Node::Matcher#assert_all_of_selectors}
RSpec matcher for whether the element(s) matching a group of selectors exist
def have_all_of_selectors(*args, &optional_filter_block)
  HaveAllSelectors.new(*args, &optional_filter_block)
end

def have_button(locator = nil, **options, &optional_filter_block)

See {Capybara::Node::Matchers#has_button?}
RSpec matcher for buttons
def have_button(locator = nil, **options, &optional_filter_block)
  HaveSelector.new(:button, locator, options, &optional_filter_block)
end

def have_checked_field(locator = nil, **options, &optional_filter_block)

See {Capybara::Node::Matchers#has_checked_field?}
RSpec matcher for checked fields
def have_checked_field(locator = nil, **options, &optional_filter_block)
  HaveSelector.new(:field, locator, options.merge(checked: true), &optional_filter_block)
end

def have_css(css, **options, &optional_filter_block)

See {Capybara::Node::Matchers#has_css?}
RSpec matcher for whether elements(s) matching a given css selector exist
def have_css(css, **options, &optional_filter_block)
  HaveSelector.new(:css, css, options, &optional_filter_block)
end

def have_current_path(path, **options)

See {Capybara::SessionMatchers#assert_current_path}
RSpec matcher for the current path
def have_current_path(path, **options)
  HaveCurrentPath.new(path, options)
end

def have_field(locator = nil, **options, &optional_filter_block)

See {Capybara::Node::Matchers#has_field?}
RSpec matcher for links
def have_field(locator = nil, **options, &optional_filter_block)
  HaveSelector.new(:field, locator, options, &optional_filter_block)
end

def have_link(locator = nil, **options, &optional_filter_block)

See {Capybara::Node::Matchers#has_link?}
RSpec matcher for links
def have_link(locator = nil, **options, &optional_filter_block)
  HaveSelector.new(:link, locator, options, &optional_filter_block)
end

def have_none_of_selectors(*args, &optional_filter_block)

See {Capybara::Node::Matcher#assert_none_of_selectors}
RSpec matcher for whether no element(s) matching a group of selectors exist
def have_none_of_selectors(*args, &optional_filter_block)
  HaveNoSelectors.new(*args, &optional_filter_block)
end

def have_select(locator = nil, **options, &optional_filter_block)

See {Capybara::Node::Matchers#has_select?}
RSpec matcher for select elements
def have_select(locator = nil, **options, &optional_filter_block)
  HaveSelector.new(:select, locator, options, &optional_filter_block)
end

def have_selector(*args, &optional_filter_block)

See {Capybara::Node::Matcher#assert_selector}
RSpec matcher for whether the element(s) matching a given selector exist
def have_selector(*args, &optional_filter_block)
  HaveSelector.new(*args, &optional_filter_block)
end

def have_table(locator = nil, **options, &optional_filter_block)

See {Capybara::Node::Matchers#has_table?}
RSpec matcher for table elements
def have_table(locator = nil, **options, &optional_filter_block)
  HaveSelector.new(:table, locator, options, &optional_filter_block)
end

def have_text(*args)

See {Capybara::SessionMatchers#assert_text}
RSpec matcher for text content
def have_text(*args)
  HaveText.new(*args)
end

def have_title(title, **options)

def have_title(title, **options)
  HaveTitle.new(title, options)
end

def have_unchecked_field(locator = nil, **options, &optional_filter_block)

See {Capybara::Node::Matchers#has_unchecked_field?}
RSpec matcher for unchecked fields
def have_unchecked_field(locator = nil, **options, &optional_filter_block)
  HaveSelector.new(:field, locator, options.merge(unchecked: true), &optional_filter_block)
end

def have_xpath(xpath, **options, &optional_filter_block)

See {Capybara::Node::Matchers#has_xpath?}
RSpec matcher for whether elements(s) matching a given xpath selector exist
def have_xpath(xpath, **options, &optional_filter_block)
  HaveSelector.new(:xpath, xpath, options, &optional_filter_block)
end

def match_css(css, **options, &optional_filter_block)

RSpec matcher for whether the current element matches a given css selector
def match_css(css, **options, &optional_filter_block)
  MatchSelector.new(:css, css, options, &optional_filter_block)
end

def match_selector(*args, &optional_filter_block)

See {Capybara::Node::Matchers#assert_matches_selector}
RSpec matcher for whether the current element matches a given selector
def match_selector(*args, &optional_filter_block)
  MatchSelector.new(*args, &optional_filter_block)
end

def match_xpath(xpath, **options, &optional_filter_block)

RSpec matcher for whether the current element matches a given xpath selector
def match_xpath(xpath, **options, &optional_filter_block)
  MatchSelector.new(:xpath, xpath, options, &optional_filter_block)
end