Class: RSpec::By::Formatter
- Inherits:
-
Core::Formatters::DocumentationFormatter
- Object
- Core::Formatters::DocumentationFormatter
- RSpec::By::Formatter
- Defined in:
- lib/rspec/by/formatter.rb
Defined Under Namespace
Classes: Bullet
Constant Summary collapse
- RIGHT_MARGIN =
80
Instance Method Summary collapse
- #bullet_end(color = :white) ⇒ Object
- #bullet_start(message, color = :white) ⇒ Object
- #by_ended(message) ⇒ Object
- #by_started(message) ⇒ Object
- #current_bullet ⇒ Object
- #current_indentation ⇒ Object
- #example_failed(failure) ⇒ Object
- #example_group_finished(_notification) ⇒ Object
- #example_group_started(notification) ⇒ Object
- #example_passed(passed) ⇒ Object
- #example_started(notification) ⇒ Object
- #indent(message) ⇒ Object
-
#initialize(output) ⇒ Formatter
constructor
A new instance of Formatter.
Constructor Details
Instance Method Details
#bullet_end(color = :white) ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/rspec/by/formatter.rb', line 82 def bullet_end(color = :white) bullet = @bullets.pop if bullet.nested? bullet. = '' end offset = RIGHT_MARGIN - bullet.offset output.puts RSpec::Core::Formatters::ConsoleCodes.wrap(bullet.delta_t.rjust(offset, ' '), color) end |
#bullet_start(message, color = :white) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/rspec/by/formatter.rb', line 70 def bullet_start(, color = :white) unless current_bullet.nested? offset = RIGHT_MARGIN - current_bullet.offset output.print RSpec::Core::Formatters::ConsoleCodes.wrap(current_bullet.delta_t.rjust(offset, ' '), color) output.puts '' current_bullet.nest end res = indent output.print RSpec::Core::Formatters::ConsoleCodes.wrap(res, color) @bullets.push(Bullet.new(res)) end |
#by_ended(message) ⇒ Object
54 55 56 |
# File 'lib/rspec/by/formatter.rb', line 54 def by_ended() bullet_end(:cyan) end |
#by_started(message) ⇒ Object
50 51 52 |
# File 'lib/rspec/by/formatter.rb', line 50 def by_started bullet_start(, :cyan) end |
#current_bullet ⇒ Object
66 67 68 |
# File 'lib/rspec/by/formatter.rb', line 66 def current_bullet @bullets.last end |
#current_indentation ⇒ Object
62 63 64 |
# File 'lib/rspec/by/formatter.rb', line 62 def current_indentation ' ' * (@bullets.size - 1) end |
#example_failed(failure) ⇒ Object
44 45 46 47 48 |
# File 'lib/rspec/by/formatter.rb', line 44 def example_failed(failure) @failed_examples << failure.example output.puts failure.fully_formatted(@failed_examples.size) bullet_end end |
#example_group_finished(_notification) ⇒ Object
32 33 34 |
# File 'lib/rspec/by/formatter.rb', line 32 def example_group_finished(_notification) @bullets.pop end |
#example_group_started(notification) ⇒ Object
28 29 30 |
# File 'lib/rspec/by/formatter.rb', line 28 def example_group_started(notification) bullet_start(notification.group.description) end |
#example_passed(passed) ⇒ Object
40 41 42 |
# File 'lib/rspec/by/formatter.rb', line 40 def example_passed(passed) bullet_end(:success) end |
#example_started(notification) ⇒ Object
36 37 38 |
# File 'lib/rspec/by/formatter.rb', line 36 def example_started(notification) bullet_start(notification.example.description) end |
#indent(message) ⇒ Object
58 59 60 |
# File 'lib/rspec/by/formatter.rb', line 58 def indent "#{current_indentation}#{}" end |