Sha256: bb6dd422d1b26ac2b6396740fca339a4925a9fec1509d3c77d30edfcc7acbba8
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
# frozen_string_literal: true module RSpecHTML # HTML DOM element abstraction class Element attr_reader :name, :element extend Forwardable def_delegators :@search, :has_css?, :has_xpath?, :include?, :text, :truncated_text, :size, :length, :[] def initialize(element, name, options: {}, siblings: []) @name = name @element = element @options = options @siblings = siblings @search = Search.new(@element, @siblings) end def present? return true if name == :document @search.present? end alias exist? present? def inspect "<#{self.class}::#{name.to_s.capitalize}>" end def to_s @element.to_s end Tags.each do |tag| define_method tag.downcase do |*args| options = args.first return @search.new_from_find(tag.downcase, options) if options.nil? @search.new_from_where(tag.downcase, options) end end def reconstituted self.class.reconstituted(name, @options) end def self.reconstituted(tag, options = {}) ReconstitutedElement.new(tag, options).to_s end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rspec-html-0.2.6 | lib/rspec_html/element.rb |
rspec-html-0.2.5 | lib/rspec_html/element.rb |