Module: ScreenObject::ScreenFactory

Includes:
PageNavigation
Defined in:
lib/screen-object/screen_factory.rb

Overview

Module to facilitate to creating of screen objects in step definitions. You can make the methods below available to all of your step definitions by adding this module to World.

If you plan to use the navigate_to method you will need to ensure you setup the possible routes ahead of time. You must always have a default route in order for this to work. Here is an example of how you define routes:

Notice the first entry of :another_route is passing an argument to the method.

Examples:

Making the ScreenFactory available to your step definitions

World ScreenObject::ScreenFactory

using a screen in a Scenario

on MyScreenObject do |screen|
  screen.name = 'Cheezy'
end

Example routes defined in env.rb

ScreenObject::ScreenFactory.routes = {
  :default => [[ScreenOne,:method1], [ScreenTwoA,:method2], [ScreenThree,:method3]],
  :another_route => [[ScreenOne,:method1, "arg1"], [ScreenTwoB,:method2b], [ScreenThree,:method3]]
}

Instance Method Summary collapse

Instance Method Details

#on(screen_class, &blk) ⇒ Object



36
37
38
39
40
# File 'lib/screen-object/screen_factory.rb', line 36

def on(screen_class, &blk)
  @current_screen = screen_class.new
  blk.call @current_screen if blk
  @current_screen
end