Class: TestBench::Output::Summary
- Inherits:
-
Object
- Object
- TestBench::Output::Summary
- Includes:
- Fixture::Output, Writer::Dependency
- Defined in:
- lib/test_bench/output/summary.rb,
lib/test_bench/output/summary/session.rb
Defined Under Namespace
Modules: Session
Instance Attribute Summary collapse
-
#current_file ⇒ Object
Returns the value of attribute current_file.
- #elapsed_time ⇒ Object
- #error_count ⇒ Object
- #errors_by_file ⇒ Object
- #failure_count ⇒ Object
- #file_count ⇒ Object
- #pass_count ⇒ Object
- #skip_count ⇒ Object
- #test_count ⇒ Object
- #timer ⇒ Object
Attributes included from Writer::Dependency
Class Method Summary collapse
Instance Method Summary collapse
- #configure(writer: nil, device: nil, styling: nil) ⇒ Object
- #enter_file(file) ⇒ Object
- #error(error) ⇒ Object
- #error_summary ⇒ Object
- #exit_file(_, _) ⇒ Object
- #finish(_) ⇒ Object
- #finish_test(_, result) ⇒ Object
- #session_summary ⇒ Object
- #skip_test(_) ⇒ Object
Instance Attribute Details
#current_file ⇒ Object
Returns the value of attribute current_file.
55 56 57 |
# File 'lib/test_bench/output/summary.rb', line 55 def current_file @current_file end |
#elapsed_time ⇒ Object
38 39 40 |
# File 'lib/test_bench/output/summary.rb', line 38 def elapsed_time @elapsed_time ||= 0 end |
#error_count ⇒ Object
33 34 35 |
# File 'lib/test_bench/output/summary.rb', line 33 def error_count @error_count ||= 0 end |
#errors_by_file ⇒ Object
48 49 50 51 52 |
# File 'lib/test_bench/output/summary.rb', line 48 def errors_by_file @errors_by_file ||= Hash.new do |hash, key| hash[key] = [] end end |
#failure_count ⇒ Object
28 29 30 |
# File 'lib/test_bench/output/summary.rb', line 28 def failure_count @failure_count ||= 0 end |
#file_count ⇒ Object
8 9 10 |
# File 'lib/test_bench/output/summary.rb', line 8 def file_count @file_count ||= 0 end |
#pass_count ⇒ Object
18 19 20 |
# File 'lib/test_bench/output/summary.rb', line 18 def pass_count @pass_count ||= 0 end |
#skip_count ⇒ Object
23 24 25 |
# File 'lib/test_bench/output/summary.rb', line 23 def skip_count @skip_count ||= 0 end |
#test_count ⇒ Object
13 14 15 |
# File 'lib/test_bench/output/summary.rb', line 13 def test_count @test_count ||= 0 end |
#timer ⇒ Object
43 44 45 |
# File 'lib/test_bench/output/summary.rb', line 43 def timer @timer ||= Timer::Substitute.build end |
Class Method Details
.build(writer: nil, device: nil, styling: nil) ⇒ Object
62 63 64 65 66 |
# File 'lib/test_bench/output/summary.rb', line 62 def self.build(writer: nil, device: nil, styling: nil) instance = new instance.configure(writer: writer, device: device, styling: styling) instance end |
Instance Method Details
#configure(writer: nil, device: nil, styling: nil) ⇒ Object
57 58 59 60 |
# File 'lib/test_bench/output/summary.rb', line 57 def configure(writer: nil, device: nil, styling: nil) Writer.configure(self, writer: writer, device: device, styling: styling) Timer.configure(self) end |
#enter_file(file) ⇒ Object
68 69 70 71 72 |
# File 'lib/test_bench/output/summary.rb', line 68 def enter_file(file) timer.start self.current_file = file end |
#error(error) ⇒ Object
96 97 98 99 100 |
# File 'lib/test_bench/output/summary.rb', line 96 def error(error) errors_by_file[current_file] << error self.error_count += 1 end |
#error_summary ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/test_bench/output/summary.rb', line 112 def error_summary return if errors_by_file.empty? writer .escape_code(:bold) .escape_code(:red) .text('Error Summary:') .escape_code(:reset_intensity) .escape_code(:reset_fg) .newline errors_by_file.each do |file, errors| error_count = errors.count writer .text(error_count.to_s.rjust(4, ' ')) .text(": #{file}") .newline errors.each do |error| writer .text(' ') .escape_code(:red) PrintError.(error, writer: writer) writer.escape_code(:reset_fg) end end writer.newline end |
#exit_file(_, _) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/test_bench/output/summary.rb', line 74 def exit_file(_, _) elapsed_time = timer.stop self.elapsed_time += elapsed_time self.file_count += 1 end |
#finish(_) ⇒ Object
102 103 104 105 106 |
# File 'lib/test_bench/output/summary.rb', line 102 def finish(_) error_summary session_summary end |
#finish_test(_, result) ⇒ Object
82 83 84 85 86 87 88 89 90 |
# File 'lib/test_bench/output/summary.rb', line 82 def finish_test(_, result) self.test_count += 1 if result self.pass_count += 1 else self.failure_count += 1 end end |
#session_summary ⇒ Object
108 109 110 |
# File 'lib/test_bench/output/summary.rb', line 108 def session_summary Session.(file_count: file_count, test_count: test_count, pass_count: pass_count, skip_count: skip_count, failure_count: failure_count, error_count: error_count, elapsed_time: elapsed_time, writer: writer) end |
#skip_test(_) ⇒ Object
92 93 94 |
# File 'lib/test_bench/output/summary.rb', line 92 def skip_test(_) self.skip_count += 1 end |