class Rutema::Step

Represents a step in a Scenario.

Each Rutema::Step can have text and a command associated with it.

Step standard attributes are.

attended - the step can only run in attended mode, it requires user input.

step_type - a string identifying the type of the step. It is “step” by default.

ignore - set to true if the step’s success or failure is to be ignored. It essentially means that the step is always considered succesfull

number - this is set when the step is assigned to a Scenario and is the sequence number

cmd - the command associated with this step. This should quack like Patir::Command.

status - one of :not_executed, :success, :warning, :error. Encapsulates the underlying command’s status

Dynamic behaviour

A Rutema::Step can be queried dynamicaly about the attributes it posesses:

step.has_script? - will return true if script is step's attribute.

Attribute’s are mostly assigned by the parser, i.e. the Rutema::BaseXMLParser from the XML element

<test script="some_script"/>

will create a Step instance with step_type==“test” and script=“some_script”. In this case

step.has_script? returns true
step.script returns "some_script"

Just like an OpenStruct, Step attributes will be created by direct assignment:

step.script="some_script" creates the script attribute if it does not exist.

See Rutema::SpecificationElement for the implementation details.

Public Class Methods

new(txt="",cmd=nil) click to toggle source

txt describes the step, cmd is the command to run

# File lib/rutema/core/objectmodel.rb, line 151
def initialize txt="",cmd=nil
  @attributes=Hash.new
  #ignore is off by default
  @attributes[:ignore]=false
  #assign
  @attributes[:cmd]=cmd if cmd
  @attributes[:text]=txt
  @number=0
  @attributes[:step_type]="step"
end

Public Instance Methods

error() click to toggle source
# File lib/rutema/core/objectmodel.rb, line 169
def error
  return "no command associated" unless @attributes[:cmd]
  return @attributes[:cmd].error
end
exec_time() click to toggle source
# File lib/rutema/core/objectmodel.rb, line 177
def exec_time
  return 0 unless @attributes[:cmd]
  return @attributes[:cmd].exec_time
end
ignore?() click to toggle source
# File lib/rutema/core/objectmodel.rb, line 173
def ignore?
  return false unless @attributes[:ignore]
  return @attributes[:ignore]
end
name() click to toggle source
# File lib/rutema/core/objectmodel.rb, line 162
def name
  return name_with_parameters
end
name_with_parameters() click to toggle source
# File lib/rutema/core/objectmodel.rb, line 195
def name_with_parameters
  param=" - #{self.cmd.to_s}" if self.has_cmd?
  return "#{@attributes[:step_type]}#{param}"
end
output() click to toggle source
# File lib/rutema/core/objectmodel.rb, line 165
def output
  return "" unless @attributes[:cmd]
  return @attributes[:cmd].output
end
reset() click to toggle source
# File lib/rutema/core/objectmodel.rb, line 192
def reset
  @attributes[:cmd].reset if @attributes[:cmd]
end
run(context=nil) click to toggle source
# File lib/rutema/core/objectmodel.rb, line 188
def run context=nil
  return not_executed unless @attributes[:cmd]
  return @attributes[:cmd].run(context)
end
status() click to toggle source
# File lib/rutema/core/objectmodel.rb, line 181
def status
  return :warning unless @attributes[:cmd]
  return @attributes[:cmd].status
end
status=(st) click to toggle source
# File lib/rutema/core/objectmodel.rb, line 185
def status= st
  @attributes[:cmd].status=st if @attributes[:cmd]
end