Module: TE3270::ScreenFactory

Includes:
PageNavigation
Defined in:
lib/te3270/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 TE3270::ScreenFactory

using a screen in a Scenario

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

Example routes defined in env.rb

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

Instance Method Summary collapse

Instance Method Details

#on(screen_class, &block) ⇒ ScreenObject

Create a screen object. Also sets an instance variable [email protected]_screen

Parameters:

  • screen_class (Class)

    a class that has included the TE3270 module

  • an (block)

    optional block to be called

Returns:

  • (ScreenObject)

    the newly created screen object


41
42
43
44
45
46
47
# File 'lib/te3270/screen_factory.rb', line 41

def on(screen_class, &block)
  return super(screen_class, &block) unless screen_class.ancestors.include? TE3270
  raise '@emulator instance variable must be available to use the ScreenFactory methods' unless @emulator
  @current_screen = screen_class.new @emulator
  block.call @current_screen if block
  @current_screen
end