module CapybaraTestHelpers::Finders

Internal: Wraps Capybara finders to be aware of the selector aliases, and to auto-wrap the returned elements with test helpers.

Public Instance Methods

all(*args, **kwargs, &filter) click to toggle source

Public: Returns all the Capybara nodes that match the specified selector.

Returns an Array of Capybara::Element that match the query.

# File lib/capybara_test_helpers/finders.rb, line 23
def all(*args, **kwargs, &filter)
  if defined?(::RSpec::Matchers::BuiltIn::All) && args.first.respond_to?(:matches?)
    ::RSpec::Matchers::BuiltIn::All.new(*args, **kwargs)
  else
    find_all(*args, **kwargs, &filter)
  end
end

Private Instance Methods

find_element(*args, **kwargs, &filter) click to toggle source

Internal: Finds an element that matches the specified locator and options.

Returns a Capybara::Node::Element that matches the conditions, or fails.

# File lib/capybara_test_helpers/finders.rb, line 36
def find_element(*args, **kwargs, &filter)
  kwargs[:test_helper] = self
  current_context.find(*args, **kwargs, &filter)
end