Sha256: 10bfd3f06e7261e80f26a2ad930d37dfb62082a9ede733856a75075e95f6dfa7

Contents?: true

Size: 578 Bytes

Versions: 5

Compression:

Stored size: 578 Bytes

Contents

require File.expand_path('../selectors/defaults', __FILE__)

def fsf(*args)
  selector        = sf(*args)
  selector_format = selector.starts_with?('.//') ? :xpath : :css

  page.find(selector_format, selector)
end

def idsf(*args)
  id_selector = sf(*args)
  id_selector.starts_with?('#') ? id_selector[1..-1] : id_selector
end

def sf(*args)
  string   = args[0]
  selector = RSpectacular::Selectors.find { |regex, selector| string.match regex }[1]

  if selector.present?
    if selector.respond_to? :call
      selector.call(*args)
    else
      selector
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rspectacular-0.27.0 lib/rspectacular/selectors.rb
rspectacular-0.26.0 lib/rspectacular/selectors.rb
rspectacular-0.25.0 lib/rspectacular/selectors.rb
rspectacular-0.24.0 lib/rspectacular/selectors.rb
rspectacular-0.23.1 lib/rspectacular/selectors.rb