Class: Testable::Page

Inherits:
Node show all
Defined in:
lib/testable/capybara/page.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#node

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#method_missing, #respond_to_missing?

Methods included from DSL

included

Constructor Details

#initialize(node: Capybara.current_session, path: nil) ⇒ Page

Returns a new instance of Page.



15
16
17
18
# File 'lib/testable/capybara/page.rb', line 15

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Testable::Node

Instance Attribute Details

#pathObject (readonly)

The ‘Page` class wraps an HTML page with an application-specific API. This can be extended to define an API for manipulating the pages of the web application.



9
10
11
# File 'lib/testable/capybara/page.rb', line 9

def path
  @path
end

Class Method Details

.visitObject



11
12
13
# File 'lib/testable/capybara/page.rb', line 11

def self.visit
  new.visit
end

Instance Method Details

#current?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/testable/capybara/page.rb', line 25

def current?
  @node.current_path == path
end

#visitObject



20
21
22
23
# File 'lib/testable/capybara/page.rb', line 20

def visit
  @node.visit(path)
  self
end