Module: TerminusSpec::Factory

Defined in:
lib/terminus_spec/factory.rb

Instance Method Summary collapse

Instance Method Details

#on(page_class, visit = false, &block) ⇒ PageObject

This is the method that creates a page object.

it is created

Parameters:

  • a (PageClass)

    class that has included the TerminusSpec module

  • a (Boolean)

    boolean indicating if the page should be visited after

  • an (block)

    optional set of logic to be called on the page object

Returns:

  • (PageObject)

    a page object



20
21
22
23
24
# File 'lib/terminus_spec/factory.rb', line 20

def on(page_class, visit=false, &block)
  @page = page_class.new(@browser, visit)
  block.call @page if block
  @page
end

#visit(page_class, &block) ⇒ PageObject

This is the method that visits a page object after it has been created.

Parameters:

  • a (PageClass)

    class that has included the TerminusSpec module

  • an (block)

    optional set of logic to be called on the page object

Returns:

  • (PageObject)

    a page object



9
10
11
# File 'lib/terminus_spec/factory.rb', line 9

def visit(page_class, &block)
  on page_class, true, &block
end