Class: Context

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/contextual/context.rb

Overview

The Context is used to pass information between different stages of a Test. Context is inherited from parent to child, but not sibling to sibling. The Context object is an OpenStruct, which means you can dynamically assign as needed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeContext

Returns a new instance of Context.



17
18
19
20
21
# File 'lib/contextual/context.rb', line 17

def initialize
  super
  @expected = nil
  @actual = nil
end

Instance Attribute Details

#actualObject

Returns actual expected object, ideally will be set during the Contexual::Node#run_action step.

Returns:

  • (Object)

    actual expected object, ideally will be set during the Contexual::Node#run_action step



12
13
14
# File 'lib/contextual/context.rb', line 12

def actual
  @actual
end

#expectedObject

Returns expected.

Returns:

  • (Object)

    expected



15
16
17
# File 'lib/contextual/context.rb', line 15

def expected
  @expected
end

Instance Method Details

#apply(parent_context) ⇒ Object

Parameters:



24
25
26
27
28
29
30
31
# File 'lib/contextual/context.rb', line 24

def apply(parent_context)
  @expected = parent_context.expected
  @actual = parent_context.actual

  parent_context.each_pair do |key, value|
    self[key] = value
  end
end