Class: Rbar::Bar
- Inherits:
-
RSpec::Core::Formatters::BaseTextFormatter
- Object
- RSpec::Core::Formatters::BaseTextFormatter
- Rbar::Bar
- Defined in:
- lib/rbar/bar.rb
Instance Attribute Summary collapse
-
#failed_bar ⇒ Object
Returns the value of attribute failed_bar.
-
#pass_bar ⇒ Object
Returns the value of attribute pass_bar.
-
#pending_bar ⇒ Object
Returns the value of attribute pending_bar.
Instance Method Summary collapse
- #dump_failures(notifi) ⇒ Object
- #dump_pending(_notifi) ⇒ Object
- #dump_summary(notifi) ⇒ Object
- #example_failed(_notification) ⇒ Object
- #example_passed(_notification) ⇒ Object
- #example_pending(_notification) ⇒ Object
- #print_failures(failed_examples) ⇒ Object
- #print_pending(pending_examples) ⇒ Object
- #print_summary(notifi) ⇒ Object
- #progress_bar ⇒ Object
- #result_color ⇒ Object
- #seed(notifi) ⇒ Object
- #start(notification) ⇒ Object
- #stop(notifi) ⇒ Object
- #width ⇒ Object
Instance Attribute Details
#failed_bar ⇒ Object
Returns the value of attribute failed_bar.
131 132 133 |
# File 'lib/rbar/bar.rb', line 131 def @failed_bar end |
#pass_bar ⇒ Object
Returns the value of attribute pass_bar.
131 132 133 |
# File 'lib/rbar/bar.rb', line 131 def @pass_bar end |
#pending_bar ⇒ Object
Returns the value of attribute pending_bar.
131 132 133 |
# File 'lib/rbar/bar.rb', line 131 def @pending_bar end |
Instance Method Details
#dump_failures(notifi) ⇒ Object
51 52 53 |
# File 'lib/rbar/bar.rb', line 51 def dump_failures(notifi) @failed = notifi.fully_formatted_failed_examples end |
#dump_pending(_notifi) ⇒ Object
55 |
# File 'lib/rbar/bar.rb', line 55 def dump_pending(_notifi); end |
#dump_summary(notifi) ⇒ Object
91 92 93 94 95 96 97 98 99 |
# File 'lib/rbar/bar.rb', line 91 def dump_summary(notifi) box = TTY::Box.frame(title: { top_left: " Seed #{@seed}" }, width: TTY::Screen.width, padding: 1) do string = @failed string << print_summary(notifi) end puts puts puts box end |
#example_failed(_notification) ⇒ Object
46 47 48 49 |
# File 'lib/rbar/bar.rb', line 46 def example_failed(_notification) .increment print @string end |
#example_passed(_notification) ⇒ Object
36 37 38 39 |
# File 'lib/rbar/bar.rb', line 36 def example_passed(_notification) .increment print @string end |
#example_pending(_notification) ⇒ Object
41 42 43 44 |
# File 'lib/rbar/bar.rb', line 41 def example_pending(_notification) .increment print @string end |
#print_failures(failed_examples) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/rbar/bar.rb', line 70 def print_failures(failed_examples) failures = failed_examples.group_by { |failure| failure.example.example_group.description } formatted_failures = failures.transform_values do |group_failures| group_failures.map do |failure| { failure.description => failure..map(&:strip) } end end TTY::Tree.new(formatted_failures) end |
#print_pending(pending_examples) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rbar/bar.rb', line 57 def print_pending(pending_examples) pending = pending_examples.group_by { |pending| pending.example_group.description } formatted_pending = pending.transform_values do |group_pending| group_pending.map do |example| { example.description => example.execution_result. } end end tree = TTY::Tree.new(formatted_pending) end |
#print_summary(notifi) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/rbar/bar.rb', line 101 def print_summary(notifi) table = TTY::Table.new(orientation: :horizontal, padding: 2) do |t| t << ['Examples', notifi.example_count] t << ['Failed', notifi.failure_count] t << ['Pending', notifi.pending_count] end table.render(:unicode, width: TTY::Screen.width) do |renderer| renderer.border.style = result_color renderer.border.separator = :each_row renderer.padding = 1 renderer.render end end |
#progress_bar ⇒ Object
127 128 129 |
# File 'lib/rbar/bar.rb', line 127 def @progress_bar ||= TTY::ProgressBar::Multi.new(width: width, clear: true) end |
#result_color ⇒ Object
116 117 118 119 120 121 |
# File 'lib/rbar/bar.rb', line 116 def result_color return :red if .progress > 0 return :yellow if .progress > 0 :green end |
#seed(notifi) ⇒ Object
83 84 85 |
# File 'lib/rbar/bar.rb', line 83 def seed(notifi) @seed = notifi.seed end |
#start(notification) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/rbar/bar.rb', line 28 def start(notification) super self.total = notification.count puts end |
#stop(notifi) ⇒ Object
123 124 125 |
# File 'lib/rbar/bar.rb', line 123 def stop(notifi) @failure_notifications = notifi.failure_notifications end |
#width ⇒ Object
87 88 89 |
# File 'lib/rbar/bar.rb', line 87 def width TTY::Screen.width * 0.75 end |