Sha256: 87a3d3ed862f75b7040b9404efe87a39e8d60dbe65d126504dbb12022e6c6b69

Contents?: true

Size: 881 Bytes

Versions: 3

Compression:

Stored size: 881 Bytes

Contents

# Allows the use of :ctype in a capybara finder spec
# the argument can either be a symbol, string or an array
# If a symbol or string, the component object is looked up by its ctype in the registry
# If an array, these are treated as multiple arguments, the first one being as above,
# and the remainder are passed on to the instance of the component object
Capybara.add_selector(:ctype) do
  xpath do |args|
    local_args = args
    local_args = [args] unless args.is_a? Array
    ctype, *other_args = local_args
    component = ::CapybaraObjects::RegistryInstance.instance.lookup_ctype(ctype).new(*other_args)
    query = ::Capybara::Query.new(*component.locator)
    selector = query.selector
    @format = selector.format
    if selector.format == :css
      @css = selector.css
      @xpath = nil
    else
      @xpath = selector.xpath
    end
    query.expression
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
capybara_objects-0.1.2 lib/capybara_objects/configure_capybara.rb
capybara_objects-0.1.1 lib/capybara_objects/configure_capybara.rb
capybara_objects-0.1.0 lib/capybara_objects/configure_capybara.rb