class Mache::Node

The {Node} class represents a wrapped HTML page, or fragment. It exposes all methods from the Mache DSL, and forwards any Capybara API methods to the {#node} object.

@abstract

Attributes

node[R]

The underlying Capybara node object wrapped by this instance.

@return [Capybara::Node] a node object

Public Class Methods

new(node:) click to toggle source

Returns a new instance of Node.

@param node [Capybara::Node] a Capybara node object to wrap

# File lib/mache/node.rb, line 20
def initialize(node:)
  @node = node
end

Public Instance Methods

empty?() click to toggle source

Tests whether the node is empty.

@return [Boolean] `true` if the node is empty, `false` otherwise.

# File lib/mache/node.rb, line 27
def empty?
  node.all('*').length.zero?
end
method_missing(name, *args, &block) click to toggle source

Forwards any Capybara API calls to the node object.

Calls superclass method
# File lib/mache/node.rb, line 32
def method_missing(name, *args, &block)
  if @node.respond_to?(name)
    @node.send(name, *args, &block)
  else
    super
  end
end
respond_to_missing?(name, include_private = false) click to toggle source

@!visibility private

Calls superclass method
# File lib/mache/node.rb, line 41
def respond_to_missing?(name, include_private = false)
  @node.respond_to?(name) || super
end