Sha256: 34d1fc347c5a7fdf70246b77044ae986861f6f0fc7491c05aadf5a2995cadaed

Contents?: true

Size: 578 Bytes

Versions: 8

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.shift
  selector = RSpectacular::Selectors.find { |regex, selector| string.match regex }

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rspectacular-0.23.0 lib/rspectacular/selectors.rb
rspectacular-0.22.2 lib/rspectacular/selectors.rb
rspectacular-0.22.1 lib/rspectacular/selectors.rb
rspectacular-0.22.0 lib/rspectacular/selectors.rb
rspectacular-0.21.6 lib/rspectacular/selectors.rb
rspectacular-0.21.5 lib/rspectacular/selectors.rb
rspectacular-0.21.4 lib/rspectacular/selectors.rb
rspectacular-0.21.3 lib/rspectacular/selectors.rb