Module: Contextual::Parent
- Included in:
- Group, TestRunner
- Defined in:
- lib/contextual/parent.rb
Overview
A Parent is a Node that can have children
Instance Attribute Summary collapse
- #children ⇒ Array<Node> readonly
Instance Method Summary collapse
- #assign_parent(parent_options) ⇒ void
-
#critical_inconclusive ⇒ TestFailure
Handles when there is a error that makes it impossible to run.
-
#failures ⇒ Integer
Counts all failures, including children.
- #get_result(filter_settings) ⇒ TestResult
-
#neutrals ⇒ Integer
Counts all neutrals, including children.
- #report_children(filter_settings) ⇒ void
- #set_parent(children = []) ⇒ Object
- #should_run_with_search_term_with_children(filter_settings) ⇒ Boolean
-
#successes ⇒ Integer
Counts all successes, including children.
-
#total ⇒ Integer
Counts all tests, including children.
Instance Attribute Details
#children ⇒ Array<Node> (readonly)
11 12 13 |
# File 'lib/contextual/parent.rb', line 11 def children @children end |
Instance Method Details
#assign_parent(parent_options) ⇒ void
This method returns an undefined value.
25 26 27 28 29 30 31 32 |
# File 'lib/contextual/parent.rb', line 25 def assign_parent() super @children.each do |child| next unless child.respond_to?(:assign_parent) child.assign_parent() end end |
#critical_inconclusive ⇒ TestFailure
Handles when there is a error that makes it impossible to run
127 128 129 130 131 132 133 |
# File 'lib/contextual/parent.rb', line 127 def critical_inconclusive super @children.each do |child| child.critical_inconclusive @test_neutral_count += 1 end end |
#failures ⇒ Integer
Counts all failures, including children
93 94 95 96 97 98 99 |
# File 'lib/contextual/parent.rb', line 93 def failures current_fail_count = @test_fail_count @children.each do |child| current_fail_count += child.failures if child.instance_of? Group end current_fail_count end |
#get_result(filter_settings) ⇒ TestResult
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/contextual/parent.rb', line 63 def get_result(filter_settings) super # This is just a stub if there's no children - do nothing return TestNeutral.new(@title, 'Empty - no tests') if @children.empty? @result = run_setup return @result unless @result.nil? @result = get_result_children(filter_settings) teardown_failure = run_teardown @result = teardown_failure unless teardown_failure.nil? @result end |
#neutrals ⇒ Integer
Counts all neutrals, including children
103 104 105 106 107 108 109 |
# File 'lib/contextual/parent.rb', line 103 def neutrals current_neutral_count = @test_neutral_count @children.each do |child| current_neutral_count += child.neutrals if child.instance_of? Group end current_neutral_count end |
#report_children(filter_settings) ⇒ void
This method returns an undefined value.
51 52 53 54 55 56 57 58 59 |
# File 'lib/contextual/parent.rb', line 51 def report_children(filter_settings) @children.each do |child| if @filter_applies_to_children child.report(filter_settings) if child.should_run_with_filter(filter_settings) else child.report(filter_settings) end end end |
#set_parent(children = []) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/contextual/parent.rb', line 14 def set_parent(children = []) @children = children @test_fail_count = 0 @test_success_count = 0 @test_neutral_count = 0 @filter_applies_to_children = false assign_children end |
#should_run_with_search_term_with_children(filter_settings) ⇒ Boolean
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/contextual/parent.rb', line 36 def should_run_with_search_term_with_children(filter_settings) # Check if the general search term applies here return true if should_run_with_search_term(filter_settings) if filter_settings.has_test_filter_term || filter_settings.has_test_search_for should_run_filter_on_children(filter_settings) end # No applicable filter true end |
#successes ⇒ Integer
Counts all successes, including children
83 84 85 86 87 88 89 |
# File 'lib/contextual/parent.rb', line 83 def successes current_success_count = @test_success_count @children.each do |child| current_success_count += child.successes if child.instance_of? Group end current_success_count end |
#total ⇒ Integer
Counts all tests, including children
113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/contextual/parent.rb', line 113 def total test_count = 0 @children.each do |child| if child.instance_of? Group test_count += child.total elsif child.instance_of?(Test) && child.ran_successfully test_count += 1 end end test_count end |