Sha256: a31a2d9b748c762845211c4f85c3e2899096cce789a8b558898131621e16d822

Contents?: true

Size: 516 Bytes

Versions: 1

Compression:

Stored size: 516 Bytes

Contents

require "capybara"
require "mache/node"

module Mache
  # A page provides a DSL for querying a wrapped capybara node object node. A
  # page can also has a path which can be visited.
  class Page < Node
    attr_reader :path

    def initialize(node: Capybara.current_session, path: nil)
      @node ||= node
      @path ||= path
    end

    def visit
      @node.visit(path)
      self
    end

    def current?
      @node.current_path == path
    end

    def self.visit
      new.tap(&:visit)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mache-1.0.0 lib/mache/page.rb