Class: Liza::TestTreePart

Inherits:
Part show all
Defined in:
lib/liza/safety_parts/test_tree_part.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Part

extension, insertion

Methods inherited from Unit

const_missing, division, part, system, #system, test_class

Constructor Details

#initialize(parent, before_stack, after_stack) ⇒ TestTreePart

Returns a new instance of TestTreePart.



49
50
51
52
53
# File 'lib/liza/safety_parts/test_tree_part.rb', line 49

def initialize parent, before_stack, after_stack
  @tests = []
  initialize_parenting parent
  initialize_filters before_stack, after_stack
end

Instance Attribute Details

#after_stackObject (readonly)

Returns the value of attribute after_stack.



47
48
49
# File 'lib/liza/safety_parts/test_tree_part.rb', line 47

def after_stack
  @after_stack
end

#before_stackObject (readonly)

Returns the value of attribute before_stack.



47
48
49
# File 'lib/liza/safety_parts/test_tree_part.rb', line 47

def before_stack
  @before_stack
end

#childrenObject (readonly)

Returns the value of attribute children.



47
48
49
# File 'lib/liza/safety_parts/test_tree_part.rb', line 47

def children
  @children
end

#parentObject (readonly)

Returns the value of attribute parent.



47
48
49
# File 'lib/liza/safety_parts/test_tree_part.rb', line 47

def parent
  @parent
end

#testsObject (readonly)

Returns the value of attribute tests.



47
48
49
# File 'lib/liza/safety_parts/test_tree_part.rb', line 47

def tests
  @tests
end

Instance Method Details

#add_after(&block) ⇒ Object



77
78
79
80
# File 'lib/liza/safety_parts/test_tree_part.rb', line 77

def add_after &block
  log "add_after to ##{object_id} #{block}" if log_test_building?
  @after_top.push block
end

#add_before(&block) ⇒ Object



67
68
69
70
# File 'lib/liza/safety_parts/test_tree_part.rb', line 67

def add_before &block
  log "add_before to ##{object_id} #{block}" if log_test_building?
  @before_top.push block
end

#add_test(words, &block) ⇒ Object



72
73
74
75
# File 'lib/liza/safety_parts/test_tree_part.rb', line 72

def add_test words, &block
  log "add_test to ##{object_id} #{words} #{block}" if log_test_building?
  tests << [words, block]
end

#branch_out(words, &block) ⇒ Object



82
83
84
# File 'lib/liza/safety_parts/test_tree_part.rb', line 82

def branch_out words, &block
  self.class.new self, before_stack.dup, after_stack.dup
end

#initialize_filters(before_stack, after_stack) ⇒ Object



61
62
63
64
65
# File 'lib/liza/safety_parts/test_tree_part.rb', line 61

def initialize_filters before_stack, after_stack
  @before_top, @after_top = [], []
  @before_stack = before_stack.push @before_top
  @after_stack  = after_stack.unshift @after_top
end

#initialize_parenting(parent) ⇒ Object



55
56
57
58
59
# File 'lib/liza/safety_parts/test_tree_part.rb', line 55

def initialize_parenting parent
  @parent = parent || self
  @children = []
  @parent.children << self if @parent != self
end

#log_test_building?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/liza/safety_parts/test_tree_part.rb', line 43

def log_test_building?
  Liza::Test.log_test_building?
end