Class: MinitestBender::States::Base
- Inherits:
-
Object
- Object
- MinitestBender::States::Base
show all
- Defined in:
- lib/minitest-bender/states/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
6
7
8
|
# File 'lib/minitest-bender/states/base.rb', line 6
def initialize
@results = []
end
|
Instance Attribute Details
#results ⇒ Object
Returns the value of attribute results.
4
5
6
|
# File 'lib/minitest-bender/states/base.rb', line 4
def results
@results
end
|
Instance Method Details
#add_result(result) ⇒ Object
10
11
12
|
# File 'lib/minitest-bender/states/base.rb', line 10
def add_result(result)
results.push(result)
end
|
#color ⇒ Object
79
80
81
|
# File 'lib/minitest-bender/states/base.rb', line 79
def color
self.class::COLOR
end
|
#colored_icon ⇒ Object
22
23
24
|
# File 'lib/minitest-bender/states/base.rb', line 22
def colored_icon
colored(icon)
end
|
#colored_icon_with_context_count(result_context, padding_right = 0) ⇒ Object
30
31
32
33
|
# File 'lib/minitest-bender/states/base.rb', line 30
def colored_icon_with_context_count(result_context, padding_right = 0)
context_count = results.count { |r| r.context == result_context }
with_colored_icon(context_count, padding_right)
end
|
#colored_icon_with_count(padding_right = 0) ⇒ Object
26
27
28
|
# File 'lib/minitest-bender/states/base.rb', line 26
def colored_icon_with_count(padding_right = 0)
with_colored_icon(results.size, padding_right)
end
|
#detail_lines(result) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/minitest-bender/states/base.rb', line 50
def detail_lines(result)
number = "#{result.execution_order})".ljust(4)
padding = ' ' * (number.size + 4)
time = "(#{result.time_with_unit_and_padding_right.strip})"
lines = []
lines << " #{number}#{result.formatted_name_with_context} #{Colorizer.colorize(time, :time)}"
lines += inner_detail_lines(result, padding)
lines << ''
lines << result.rerun_line(padding)
lines
end
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/minitest-bender/states/base.rb', line 64
def (result)
number = "#{result.execution_order})".ljust(4)
padding = ' ' * (number.size + 2)
lines = []
lines += inner_detail_lines(result, padding).tap do |ls|
ls[0] = " #{number}#{ls[0].strip}" unless ls.empty?
end
lines << ''
lines << result.rerun_line(padding)
lines << ''
lines
end
|
18
19
20
|
# File 'lib/minitest-bender/states/base.rb', line 18
def formatted_group_label
@formatted_group_label ||= " #{colored(group_label, :bold, :underline)}"
end
|
14
15
16
|
# File 'lib/minitest-bender/states/base.rb', line 14
def formatted_label
@formatted_label ||= colored(label.ljust(7))
end
|
#print_details(io) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/minitest-bender/states/base.rb', line 35
def print_details(io)
return :no_details if results.empty?
sorted_results = results.sort_by(&:source_location)
io.puts formatted_group_label
io.puts
sorted_results.each_with_index do |result, i|
detail_lines(result).each { |line| io.puts line }
io.puts if i < results.size - 1
end
io.puts
:printed_details
end
|
#test_location(result) ⇒ Object
83
84
85
|
# File 'lib/minitest-bender/states/base.rb', line 83
def test_location(result)
location(result)
end
|