Class: Lopata::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/lopata/configuration.rb

Overview

Stores runtime configuration information

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Build an object to store runtime configuration options and set defaults



8
9
10
11
12
13
14
15
# File 'lib/lopata/configuration.rb', line 8

def initialize
  @before_start_hooks = []
  @before_scenario_steps = []
  @after_scenario_steps = []
  @observers = [Lopata::Observers::ConsoleOutputObserver.new]
  @role_descriptions = {}
  @env = :qa
end

Instance Attribute Details

#default_roleSymbol?

Returns user role to be used in scenario if not specified.

Returns:

  • (Symbol, nil)

    user role to be used in scenario if not specified

See Also:



104
105
106
# File 'lib/lopata/configuration.rb', line 104

def default_role
  @default_role
end

#envSymbol

Returns environment code. Default is :qa.

Returns:

  • (Symbol)

    environment code. Default is :qa

See Also:



109
110
111
# File 'lib/lopata/configuration.rb', line 109

def env
  @env
end

#keepBoolean

Returns keep generated test data after scenarios running. Default is false Set to true for keeping generated data. Use ‘lopata –keep’ modifier to set keep mode on running.

Returns:

  • (Boolean)

    keep generated test data after scenarios running. Default is false Set to true for keeping generated data. Use ‘lopata –keep’ modifier to set keep mode on running.

See Also:



116
117
118
# File 'lib/lopata/configuration.rb', line 116

def keep
  @keep
end

#role_descriptionsHash{Symbol => String}

Returns map or role codes to role name.

Returns:

  • (Hash{Symbol => String})

    map or role codes to role name.

See Also:



100
101
102
# File 'lib/lopata/configuration.rb', line 100

def role_descriptions
  @role_descriptions
end

Instance Method Details

#add_observer(observer) ⇒ Object

Add an observer to the set Lopata to be used for this run.

Parameters:

  • observer (Lopata::Observers::BaseObserver)

    a observer instance.

See Also:

  • Observers::BaseObserver


76
77
78
# File 'lib/lopata/configuration.rb', line 76

def add_observer(observer)
  @observers << observer
end

#after_scenario(*steps, &block) ⇒ Object

Defines ‘after scenario’ steps. Given steps will be runned after each scenario in context of scenario. It may be shared step names, and|or block.

Examples:

Lopata.configure do |c|
  c.after_scenario 'cleanup test user'
end

Parameters:

  • steps (Array<String>)

    name of shared steps

  • block (Proc)

    block of code



63
64
65
66
# File 'lib/lopata/configuration.rb', line 63

def after_scenario(*steps, &block)
  after_scenario_steps.append(*steps) unless steps.empty?
  after_scenario_steps.append(block) if block_given?
end

#before_scenario(*steps, &block) ⇒ Object

Defines ‘before scenario’ steps. Given steps will be runned before each scenario in context of scenario. It may be shared step names, and|or block.

Examples:

Lopata.configure do |c|
  c.before_scenario 'setup test user'
end

Parameters:

  • steps (Array<String>)

    name of shared steps

  • block (Proc)

    block of code



47
48
49
50
# File 'lib/lopata/configuration.rb', line 47

def before_scenario(*steps, &block)
  before_scenario_steps.append(*steps) unless steps.empty?
  before_scenario_steps.append(block) if block_given?
end

#before_start(&block) ⇒ Object

Add the hook to be called before scenarios running The block will be called after framework initialization and before scenarios parsing. It usually allow to require and initialize the libraries used for project testing.

Examples:

Lopata.configure do |c|
  c.before_start do
    require 'active_record'
  end
end


27
28
29
# File 'lib/lopata/configuration.rb', line 27

def before_start(&block)
  @before_start_hooks << block
end